phpmailer-amp / phpmailer-amp
PHPMailer-AMP is the same PHPMailer library with AMP content support
v1.1.0
2024-08-24 19:18 UTC
Requires
- php: >=5.5.0
- ext-ctype: *
- ext-filter: *
- ext-hash: *
Requires (Dev)
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- doctrine/annotations: ^1.2.6 || ^1.13.3
- php-parallel-lint/php-console-highlighter: ^1.0.0
- php-parallel-lint/php-parallel-lint: ^1.3.2
- phpcompatibility/php-compatibility: ^9.3.5
- roave/security-advisories: dev-latest
- squizlabs/php_codesniffer: ^3.7.2
- yoast/phpunit-polyfills: ^1.0.4
Suggests
- ext-mbstring: Needed to send email in multibyte encoding charset or decode encoded addresses
- ext-openssl: Needed for secure SMTP sending and DKIM signing
- decomplexity/SendOauth2: Adapter for using XOAUTH2 authentication
- greew/oauth2-azure-provider: Needed for Microsoft Azure XOAUTH2 authentication
- hayageek/oauth2-yahoo: Needed for Yahoo XOAUTH2 authentication
- league/oauth2-google: Needed for Google XOAUTH2 authentication
- psr/log: For optional PSR-3 debug logging
- symfony/polyfill-mbstring: To support UTF-8 if the Mbstring PHP extension is not enabled (^1.2)
- thenetworg/oauth2-azure: Needed for Microsoft XOAUTH2 authentication
This package is not auto-updated.
Last update: 2025-07-12 23:37:26 UTC
README
Features
AMPBody
propertyisAMP()
function- Building function
msgAMP()
- 5 new message types - amp, alt_amp, alt_amp_inline, alt_amp_attach and alt_amp_inline_attach (mixed plain text, html and amp content and html, amp with attachments)
License
This software is distributed under the LGPL 2.1 license, along with the GPL Cooperation Commitment. Please read LICENSE for information on the software availability and distribution.
Installation & loading
PHPMailer is available on Packagist (using semantic versioning), and installation via Composer is the recommended way to install PHPMailer. Just add this line to your composer.json
file:
"phpmailer-amp/phpmailer-amp": "^1.1.0"
or run
composer require phpmailer-amp/phpmailer-amp
<?php use PHPMailerAMP\PHPMailerAMP;
An example how to send message with AMP content
<?php //Import PHPMailer classes into the global namespace //These must be at the top of your script, not inside a function use PHPMailerAMP\PHPMailerAMP\PHPMailer; use PHPMailerAMP\PHPMailerAMP\SMTP; use PHPMailerAMP\PHPMailerAMP\Exception; //Load Composer's autoloader require 'vendor/autoload.php'; //Create an instance; passing `true` enables exceptions $mail = new PHPMailerAMP(true); try { //Server settings $mail->SMTPDebug = SMTP::DEBUG_SERVER; //Enable verbose debug output $mail->isSMTP(); //Send using SMTP $mail->Host = 'smtp.example.com'; //Set the SMTP server to send through $mail->SMTPAuth = true; //Enable SMTP authentication $mail->Username = 'user@example.com'; //SMTP username $mail->Password = 'secret'; //SMTP password $mail->SMTPSecure = PHPMailer::ENCRYPTION_SMTPS; //Enable implicit TLS encryption $mail->Port = 465; //TCP port to connect to; use 587 if you have set `SMTPSecure = PHPMailer::ENCRYPTION_STARTTLS` //Recipients $mail->setFrom('from@example.com', 'Mailer'); $mail->addAddress('joe@example.net', 'Joe User'); //Add a recipient $mail->addAddress('ellen@example.com'); //Name is optional $mail->addReplyTo('info@example.com', 'Information'); $mail->addCC('cc@example.com'); $mail->addBCC('bcc@example.com'); //Attachments $mail->addAttachment('/var/tmp/file.tar.gz'); //Add attachments $mail->addAttachment('/tmp/image.jpg', 'new.jpg'); //Optional name //Content $mail->isHTML(true); //Set email format to HTML $mail->isAMP(true); //Enable AMP content $mail->Subject = 'Here is the subject'; $mail->AmpBody = 'This is the AMP message body <style amp4email-boilerplate>body{visibility:hidden}</style>' $mail->Body = 'This is the HTML message body <b>in bold!</b>'; $mail->AltBody = 'This is the body in plain text for non-HTML mail clients'; $mail->send(); echo 'Message has been sent'; } catch (Exception $e) { echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}"; }
Feature plans
- Code refactoring