【发布时间】:2015-10-08 19:47:37
【问题描述】:
我想做一个发送邮件的助手,我是从为我的助手做提供者和自定义类开始的。
-
我的提供者注册功能:
public function register() { $this->app->bind('mailer.helper', function (Application $app){ return new MailerHelper($app->make('mailer')); }); } -
我的辅助函数:
class MailerHelper implements SelfHandling{ /** @var Mailer $mailer */ protected $mailer; public function __construct(Mailer $mailer) { $this->mailer=$mailer; } public function sendFromContact(array $date){ $this->mailer->send('email_templates/contact', $date, function (Message $message){ $message->setTo('stroia.laurentiu92@gmail.com'); $message->setFrom('contact@dianabotezan.ro','Contact website Diana Botezan'); $message->setSubject('Forumlar contact'); }); } } -
我的配置来自 config/mail.php:
return [ 'driver' => env('MAIL_DRIVER', 'smtp'), 'host' => env('MAIL_HOST', 'smtp.gmail.com'), 'port' => env('MAIL_PORT', 587), 'from' => ['address' => null, 'name' => null], 'encryption' => env('MAIL_ENCRYPTION', 'ssl'), 'username' => env('my_gmal@gmail.com'), 'password' => env('mypassword'), 'sendmail' => '/usr/sbin/sendmail -bs', 'pretend' => false, ]'
问题是 laravel 的配置不好,这是我尝试做的事情:
Connection could not be established with host 127.0.0.1 [Connection refused #111]
1. in StreamBuffer.php line 265
2. at Swift_Transport_StreamBuffer->_establishSocketConnection() in StreamBuffer.php line 62
3. at Swift_Transport_StreamBuffer->initialize(array('protocol' => null, 'host' => '127.0.0.1', 'port' => '2525', 'timeout' => '30', 'blocking' => '1', 'tls' => false, 'type' => '1')) in AbstractSmtpTransport.php line 113
在这里你可以观察到他有其他配置然后我设置它。我做错了什么?
【问题讨论】: