jalle19 / sanemail
为希望保持理智的人提供的 Zend Mail 包装器
1.0.0
2013-07-25 09:58 UTC
Requires
- zendframework/zend-mail: 2.2.*
This package is auto-updated.
Last update: 2024-09-13 00:12:16 UTC
README
对于那些希望在不使用 ZF1 的情况下保持理智的人来说,这是一个为 Zend Mail 提供的包装器。它提供了一个简单的解决方案,无需编写 50 行代码即可发送电子邮件,并且与按照 ZF2 文档进行的方式相比,这种方法实际上可行。
特性
- 进行适当的魔法,以确保 Zend\Mail 实际上使用您指定的编码
- 始终在 HTML 版本之前设置纯文本版本,以确保您的电子邮件实际上能够正确显示
- 正确设置包含纯文本和 HTML 版本的电子邮件的 Content-Type,以便,正如理智的人所期望的,显示 HTML 版本,除非用户请求纯文本版本
安装
通过 Composer 安装
使用方法
$mail = new SaneMail\Mail(); $mail->addFrom('from@example.com', 'Disgruntled programmer'); $mail->addTo('to@example.com'); $mail->addCc('cc@example.com'); $mail->addBcc('bcc@example.com'); $mail->addReplyTo('replyto@example.com'); $mail->setSubject('This is a working e-mail'); $html = '<html><head><title></title></head><body><h1>This is HTML</h1><p>This is a paragraph</p></body></html>'; $text = "This is plain-text\n\nThis is a paragraph"; $mail->setBodyText($text); $mail->setBodyHtml($html); try { $mail->send(); } catch(SaneMail\Exception $e) { // Zend\Mail\Exception\RuntimeException available from $e->getPrevious() }
许可证
此库采用 MIT 许可证授权