I am sending email through php using smtp and using Swift_Mailer
Code:
error_log("Sending Email\n");
// 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?