I am trying to send email in Laravel
using Swift Mailer
, i have been trying from last 3 days but No Luck
.
I have Godaddy Shared hosting, i already discussed with Customer Support
, they said there is no issue from there side
I am not able to find what is wrong in this code.
Already Referred this post but didn't get any solutions.
- Laravel - Connection could not be established with host smtp.gmail.com [ #0]
- Swift_TransportException Connection could not be established with host smtp.gmail.com
- Connection could not be established with host smtp.gmail.com [Connection timed out #110] in laravel 5.2
- How to resolve the error: Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
Code
$transport = \Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, "ssl")
->setUsername('[email protected]')
->setPassword('*****');
$nam = 'abc';
$from = '[email protected]';
$message = \Swift_Message::newInstance($subject)
->setFrom(array($from => $name))
->setTo(array($to))
->setBody($body);
$message->setContentType("text/html");
$mailer = \Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);
return $result;
Please ignore Variable declaration, like $subject and ect....
Port Tried.
1. 465
2. 587
3. 80
4. 25
5. 110 ( Gmail Commercial Email )
It's showing error
Message: fsockopen(): unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
Godaddy Shared hosting
there's your problem – Ian