andrelohmann-silverstripe / smtpmailer
此包最新版本(3.1.0)没有可用的许可信息。
SMTPMailer for Silverstripe
3.1.0
2016-05-13 11:12 UTC
Requires
- php: >=5.3.2
- composer/installers: *
README
要求
Silverstripe 3.3.x
安装
将以下内容添加到您的 _ss_environment.php 文件中
// smtpmailer define('SMTPMAILER', json_encode([ "charset_encoding" => "utf-8", // E-mails characters encoding, e.g. : 'utf-8' or 'iso-8859-1' "debug_level" => "0", // Print debugging informations. 0 = no debuging, 1 = print errors, 2 = print errors and messages, 4 = print full activity "debug_stop" => true, // Stop Script on debugging. true = echo and die, false = echo can be catched by ob_start(); $var = ob_get_clean(); "credentials" => [ "default" => [ "server_address" => "smtp.gmail.com", // SMTP server address "server_port" => "465", // SMTP server port. Set to 25 if no encryption or tls. Set to 465 if ssl "secure_connection" => "ssl", // SMTP encryption method : Set to '' or 'tls' or 'ssl' "do_authenticate" => true, // Turn on SMTP server authentication. Set to false for an anonymous connection "username" => "__EMAILADDRESS__", // SMTP server username, if do_authenticate == true "password" => "__PASSWORD__", // SMTP server password, if do_authenticate == true "from" => "__EMAILADDRESS__" // From Address: e.g. "My Name" <my.account@gmail.com>, optional, use when from address needs to be fixed ], "log" => false // false or array with credentials ] ])); // Error Log Email Address define('LOG_EMAIL','__EMAIL__'); // logs will be send to this address, if defined
默认和日志凭据是必需的。如果您想在自己的应用程序中提供不同的SMTP网关,只需将它们添加到凭据数组中即可。
选择特定电子邮件的特定凭据集,可以通过设置凭据配置完成。
Config::inst()->update('SmtpMailer', 'credentials', '__CREDENTIALS_SET__'); // "default" by default
示例
用于获取调试返回代码并在您的应用程序中使用它的示例代码
$settings = Config::inst()->get('SmtpMailer', 'settings');
$settings['debug_level'] = 4;
$settings['debug_stop'] = false;
Config::inst()->update('SmtpMailer', 'settings', $settings);
// start collecting the echo messages
ob_start();
// SEND MAIL
$email = new Email();
$email->setTo(__EMAIL__);
$email->setSubject(__SUBJECT__);
$email->setBody(__BODY__);
$success = $email->sendPlain();
// write echo messages into Variable
$echoes = ob_get_clean();
if(!success) die($echoes);
注意
此存储库使用git flow范式。在每个发布周期后,不要忘记将标签、master和develop推送到远程起源。
git push --tags
git push origin develop
git push origin master