// Create the mail transport configuration
$transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
->setUsername(PASUPUKUMKUMA_EMAIL)
->setPassword(PASUPUKUMKUMA_PASS);
// Create the message
$message = Swift_Message::newInstance()
->setTo(array($email => $name))
->setSubject("Registration Success !")
->setBody('You have Registered Successfully ! Thank You For Registering With Us.Click the link to confirm your account <a href='.site_url().'/main/confirm/'.$name.'/'.$ran.'>confirm here</a>', 'text/html')
->setFrom(PASUPUKUMKUMA_EMAIL,EMAIL_FROM_NAME);
// Send the email
$mailer = Swift_Mailer::newInstance($transport);
$mailer->send($message);
这是我通过swift邮件发送电子邮件的代码当我在本地发送邮件时,一切都很完美我可以成功发送邮件。
当来到具有相同代码的实时网站时,无法发送邮件并显示错误:
Connection could not be established with host smtp.gmail.com..