0
// 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);

This is my code for sending email through swift mailer everything was perfect when I send the mail in the local I can be able to send the mail successfully.

When comes to live website with the same code not able to send the mail and shows the error:

Connection could not be established with host smtp.gmail.com..
Michaël
  • 3,679
  • 7
  • 39
  • 64

1 Answers1

0

https://www.google.com/settings/security/lesssecureapps

Turn it on for the account that you are using. Hope it will help.