descubraomundo / notifymehq-mail
为notifyme提供邮件网关
v2.0.4
2016-08-17 14:31 UTC
Requires
- php: >=5.5.9
- graham-campbell/manager: ~2.0
- illuminate/contracts: ~5.0
- illuminate/support: ~5.0
- soundasleep/html2text: ~0.2
- swiftmailer/swiftmailer: ~5.4
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-09-24 05:42:38 UTC
README
NotifyMeHQ Mail
非官方 的NotifyMeHQ邮件网关,因为它们“故意移除了邮件支持”。
如果您想保留NotifyMeHQ的默认合约 public function notify($to, $message);
,其中两个参数都是字符串,预期的行为是
- 电子邮件通知的收件人姓名将不会出现在收件人信息中,只有电子邮件地址。
- 电子邮件的主题将是
$message
内容的前75个字符,但会移除所有HTML标签。 - 电子邮件正文将是
$message
的内容,包含所有HTML标签。* 如果电子邮件正文是HTML,它将自动创建一个格式与HTML相同的纯文本版本,从而降低该电子邮件的垃圾邮件评分。* 如果正文没有HTML,将以纯文本形式发送。
否则,您可以发送包含以下配置的 $message
变量作为数组。
配置
以下是您可以为您的notifierFactory和通知提供的所有可用配置列表。
通知器
通知
如果您提供以下任何配置,它们将覆盖notifierFactory提供的默认配置。
高级
正文
对于正文值,您可以提供两种版本(HTML和纯文本)
'body' => [ 'html' => 'My <em>amazing</em> body', 'plain' => 'My amazing body' ],
或者您只能提供一个版本,我们将自动检测它是HTML还是纯文本,并正确配置
'body' => 'My <em>amazing</em> body' // It will be sent as HTML
或者
'body' => 'My amazing body' // It will be sent as plain text
发件人、收件人、抄送、密送、回复地址
对于所有电子邮件收件人/发件人配置,您可以提供两种变体
电子邮件和姓名(作为数组)
'from|to|cc|bcc|replyTo' => ['email@example.com', 'Example Name'],
仅电子邮件(作为字符串)
'from|to|cc|bcc|replyTo' => 'email@example.com',
优先级
此配置接受介于1和5之间的整数值
- 最高(1)
- 高(2)
- 正常(3)
- 低(4)
- 最低(5)
示例
<?php // Create a factory for notifications. $notifierFactory = new NotifyMeHQ\NotifyMe\NotifyMeFactory(); // Create the new notification for mail. $mailNotifier = $notifierFactory->make([ // Specify that we will use mail. 'driver' => 'mail', // Specify your SMTP Server Host. 'host' => '', // Specify your SMTP Server Port, check with your host. Eg: 25 or 465 or 2525. 'port' => 25, // Specify your SMTP Server Username. 'username' => '', // Specify your SMTP Server Password. 'password' => '', // Specify your Sender details. It can be a simple email, or a email with a name. 'from' => ['from@example.com','Example Sender'], // Email & Name ]); /** * RECIPIENTS: */ $recipient = ['recipient@example.com', 'Recipient Name']; /** * EMAIL */ $email = [ // Specifies the subject line that is displayed in the recipients' mail client 'subject' => 'Test', // Specifies the body of the email that the recipient will receive. 'body' => [ 'html' => 'My <em>amazing</em> body', 'plain' => 'My amazing body' ], // Specifies the addresses of recipients who will be copied in on the message 'cc' => ['cc@email.com', 'CC Name'], // Specifies the addresses of recipients who the message will be blind-copied to. Other recipients will not be aware of these copies. 'bcc' => ['bcc@email.com', 'BCC Name'], // Specifies the address where replies are sent to 'replyTo' => ['replyto@email.com', 'Reply To Name'], // Specifies the sender address if you want to overwrite the value set on the configuration properties. 'from' => ['otherFrom@email.com', 'Other Sender Name'], /** * ADVANCED OPTIONS */ // Specifies the format of the message (usually text/plain or text/html) 'contentType' => 'text/html', // Specifies where bounces should go (Swift Mailer reads this for other uses) 'returnPath' => 'bounces@email.com', // Specifies the email priority. 'priority' => '2', // Indicates "High" priority. ]; /* @var \NotifyMeHQ\Contracts\ResponseInterface $response */ $response = $mailNotifier->notify($recipient, $email); echo $response->isSent() ? 'Message sent' : 'Message going nowhere';
待办事项
- 添加测试
许可
NotifyMe是在MIT许可(MIT)下许可的。