drewlabs/envoyer-smtp

envoyer 客户端库的 SMTP 驱动程序

v0.2.2 2024-06-21 17:04 UTC

This package is auto-updated.

Last update: 2024-09-21 17:40:11 UTC


README

SMTP 驱动程序提供了 drewlabs/envoyer 驱动程序或客户端接口的实现,该接口使用 SMTP 协议内部发送文本消息以发送电子邮件。

用法

use Drewlabs\Envoyer\Drivers\Smtp\SymfonyMailerAdapter;
use Drewlabs\Envoyer\Mail;
use Drewlabs\Envoyer\SMTPServer;

$config = require  __DIR__ . '/contents/config.php';

// Create mail instance
$mail = Mail::new()
    ->from($config['email'])
    ->to('azandrewdevelopper@gmail.com')
    ->subject('No Attachment Registration')
    ->content(require __DIR__ . '/contents/mail.php');

// Create SMTP server configuration object
$smtpServer = new SMTPServer($config['host'], $config['port'], $config['user'], $config['password']);

// Create Symfony mailer object
$adapter = new SymfonyMailerAdapter($smtpServer->withEncryption('tls'));

// Send mail request
$result = $adapter->sendRequest($mail);