I am using Laravel 5.1 , I want to send email (smtp) this is my .env
config :
MAIL_DRIVER=smtp
MAIL_HOST=mail.mydomain.ir
MAIL_PORT=587
MAIL_USERNAME=account@mydomain.ir
MAIL_PASSWORD= ....
MAIL_ENCRYPTION=null
and this in config/mail.php
:
'from' => ['address' =>env('MAIL_USERNAME', 'account@mydomain.ir'), 'name' => 'ESET'],
and a test function to send an simple test email :
public function getEm()
{
$input = [] ;
Mail::send('emails.simple', $input, function($message) {
$message->to('some@gmail.com', 'Learning')->subject('Contact view Our Contact Form');
});
return 'Your message has been sent';
}
and when I test this project in localhost ( in WampServer) I works good and sends email ok !
But when I want to use it in server(online) I will change my .env
config as my host support says like this :
MAIL_DRIVER=smtp
MAIL_HOST=localhost
MAIL_PORT=587
MAIL_USERNAME=account@mydomain.ir
MAIL_PASSWORD=....
MAIL_ENCRYPTION=null
I See this error :
ErrorException in StreamBuffer.php line 275:
stream_set_blocking() expects parameter 1 to be resource, null given
in StreamBuffer.php line 275 at HandleExceptions->handleError('2', 'stream_set_blocking() expects parameter 1 to be resource, null given', '/home2/net45987/domains/http://ift.tt/1RXS4Y1', '275', array('host' => 'localhost', 'timeout' => '30', 'options' => array(), 'streamContext' => resource, 'errno' => null, 'errstr' => null)) at stream_set_blocking(null, '1') in StreamBuffer.php line 275 at Swift_Transport_StreamBuffer->_establishSocketConnection() in StreamBuffer.php line 62 at Swift_Transport_StreamBuffer->initialize(array('protocol' => null, 'host' => 'localhost', 'port' => '587', 'timeout' => '30', 'blocking' => '1', 'tls' => false, 'type' => '1', 'stream_context_options' => array())) in AbstractSmtpTransport.php line 113 at Swift_Transport_AbstractSmtpTransport->start() in Mailer.php line 79 at Swift_Mailer->send(object(Swift_Message), array()) in Mailer.php line 395 at Mailer->sendSwiftMessage(object(Swift_Message)) in Mailer.php line 181 at Mailer->send('emails.simple', array(), object(Closure)) in Facade.php line 222 at Facade::__callStatic('send', array('emails.simple', array(), object(Closure))) in CallbackController.php line 114 at Mail::send('emails.simple', array(), object(Closure)) in CallbackController.php line 114 at CallbackController->getEm()
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire