If i use
$transport = Swift_SmtpTransport::newInstance('localhost', 25);
then it's working fine
but when i'm using this settings it's not working
$transport = Swift_SmtpTransport::newInstance('smtp.mailgun.org', 465, 'ssl')
->setUsername('mailegun username')
->setPassword('mailgun password');
This problem is in "godaddy" and "bluehost" account
but in localhost using xampp it's working fine
<?php
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
require_once __dir__.'/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
$userBody="user mail";
$userSub = "user subject";
//$transport = Swift_SmtpTransport::newInstance('localhost', 25);
$transport = Swift_SmtpTransport::newInstance('smtp.mailgun.org', 465, 'ssl')
->setUsername('mailegun username')
->setPassword('mailgun password');
// and also not working for gmail settings
// $transport = Swift_SmtpTransport::newInstance('smtp.gmail.com', 465, 'ssl')
// ->setUsername('gmail username')
// ->setPassword('gmail password');
$userMailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance('Wonderful Subject')
->setFrom(array('ex1@gmail.com' => 'user1'))
->setTo(array('ex2@gmail.com'=> 'user2'))
->setBody('Test Message Body')
;
$sendUserMail = $userMailer->send($message,$F);
var_dump($sendUserMail);
?>