: SwiftMailer - fsockopen() error 500 I am sending email through php using smtp and using Swift_Mailer Code: error_log("Sending Emailn"); // Get mailer $SM = Yii::app()->swiftMailer;
I am sending email through php using smtp and using Swift_Mailer
Code:
error_log("Sending Emailn");
// Get mailer
$SM = Yii::app()->swiftMailer;
// Get config
$mailHost = 'smtp.gmail.com';
$mailPort = 465;
$security = 'ssl';
// New transport
$Transport = $SM->smtpTransport($mailHost, $mailPort, $security)
->setUsername('username@gmail.com')
->setPassword('password');
// Mailer
$Mailer = $SM->mailer($Transport);
// New message
$Message = $SM
->newMessage($subject)
->setFrom('username@gmail.com')
->setTo($to)
->setBody($body);
// Send mail
$result = $Mailer->send($Message);
Error:
fsockopen() [function.fsockopen]: >unable to connect to ssl://smtp.gmail.com:465 (Connection refused)
Also
PLEASE NOTE THAT: There is no SSL Certificate attached to my hosting server account.
PLEASE NOTE THAT: I am not getting the error at my local computer.
Question
Do I need SSL certificates at my hosting account? (need to confirm)
if not, then what I am getting wrong in this?
More posts by @Odierno851
1 Comments
Sorted by latest first Latest Oldest Best
You do not need a SSL certificate in order to send a secure email, the same way desktop computers, tablets and mobiles phones don't need one either.
This could be happening because your server doesn't have OpenSSL installed, or your script is at fault. You can check if you have OpenSSL installed by doing: openssl version. If you need to install OpenSSL then do the following:
sudo apt-get install openssl
sudo apt-get install libssl-dev
If you used shared hosting or another hosting environment that does not allow install of core system applications then you need to contact your web host. If you issue is with the script then Pro Webmasters is not the idea stack for this question and your need to ask on Stack Overflow, since its programming related.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.