dongshang5862 2016-04-25 12:47 采纳率: 0%
浏览 40
已采纳

无法与主机smtp.mailgun.org [关闭]建立SwiftMailer连接

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


    ?>
  • 写回答

1条回答 默认 最新

  • dtj88302 2016-04-25 12:57
    关注

    This is a well-known problem: GoDaddy does not allow outbound SMTP; you must relay through thir servers. This is covered in the PHPMailer troubleshooting guide, the principles of which still apply to SwiftMailer.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)