uom / tk-mail
使用PHPMailer为tk库提供的邮件库
3.2.0
2022-03-03 00:00 UTC
Requires
- phpmailer/phpmailer: ~6.0
- uom/tk-framework: ~3.2.0
This package is auto-updated.
Last update: 2024-09-29 05:57:07 UTC
README
项目: tk-mail
网站: https://github.com/tropotek/tk-mail/
作者: Michael Mifsud http://www.tropotek.com/
为Tk库提供的邮件库。使用PHPMailer作为邮件驱动程序。
内容
安装
可在Packagist上找到(ttek/tk-mail)并通过Composer安装。
composer require ttek/tk-mail
或者将以下内容添加到您的composer.json文件中
"ttek/tk-mail": "~3.0"
简介
基本示例
$message = new \Tk\Mail\Message(); $message->addTo('info@tropotek.com'); $message->setFrom('godar@tropotek.com.au'); $message->setSubject('This is a test email'); $message->setBody(\App\Config::createMailTemplate('This is some message text')); $message->send();
可用的配置参数
/* Default config options */ $cfg = array(); /* * Options mail, smtp, sendmail, qmail */ $cfg['mail.driver'] = 'mail'; /* * SMTP settings */ /** * SMTP hosts. * Either a single hostname or multiple semicolon-delimited hostnames. * You can also specify a different port * for each host by using this format: [hostname:port] * (e.g. "smtp1.example.com:25;smtp2.example.com"). * You can also specify encryption type, for example: * (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465"). * Hosts will be tried in order. * @var string */ $cfg['mail.smtp.host'] = 'localhost'; // The default SMTP server port. $cfg['mail.smtp.port'] = 25; $cfg['mail.smtp.username'] = ''; $cfg['mail.smtp.password'] = ''; // What kind of encryption to use on the SMTP connection. Options: '', 'ssl' or 'tls' $cfg['mail.smtp.secure'] = ''; // Whether to use SMTP authentication. Uses the Username and Password properties. $cfg['mail.smtp.enableAuth'] = true; // Whether to keep SMTP connection open after each message. If this is set to true // then to close the connection requires an explicit call to smtpClose(). $cfg['mail.smtp.enableKeepAlive'] = ''; // Checks if the send command was called from this site $cfg['mail.checkReferer'] = true; // Add valid domain names as valid referers if needed $cfg['mail.validReferers'] = ''; /* * Other misc options * Generally from the site config */ // Set this if you want all email to go to this address during debug //$cfg['system.debug.email'] = 'debug@'.$_SERVER['HTTP_HOST']; // \Tk\Request Used to set the X-Sender-IP, X-Referer headers //$cfg['request'] = ''; // \Tk\Session Used to set the X-SiteReferer header //$cfg['session'] = ''; // If true then all outgoing messages are sent to the `system.debug.email` address //$cfg['debug'] = false; // If set X-Application will be set to this //$cfg['system.name'] = ''; //$cfg['system.version'] = ''; // Change this to suite your message body encoding //$cfg['mail.encoding'] = 'UTF-8';