phpmailer-amp / phpmailer-amp
PHPMailer-AMP 是支持 AMP 内容的 PHPMailer 库
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: 2024-09-21 19:42:29 UTC
README
特性
AMPBody
属性isAMP()
函数- 构建函数
msgAMP()
- 5 种新的消息类型 - amp, alt_amp, alt_amp_inline, alt_amp_attach 和 alt_amp_inline_attach (混合纯文本、html 和 amp 内容以及带附件的 html, amp)
许可证
此软件根据 LGPL 2.1 许可证分发,附带 GPL 合作承诺。请阅读 LICENSE 了解软件的可用性和分发信息。
安装与加载
PHPMailer 可在 Packagist 上找到(使用语义版本控制),并通过 Composer 安装是推荐的方式。只需将以下行添加到您的 composer.json
文件中
"phpmailer-amp/phpmailer-amp": "^1.1.0"
或者运行
composer require phpmailer-amp/phpmailer-amp
<?php use PHPMailerAMP\PHPMailerAMP;
发送带有 AMP 内容的消息的示例
<?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}"; }
特性计划
- 代码重构