Swift邮件程序从gmail发送邮件正在运行,但不是来自网络邮件

时间:2016-03-28 11:57:18

标签: php

如果我从gmail帐户发送邮件,如someone@gmail.com到另一个Gmail或雅虎帐户,它的工作原理 但
如果我发送邮件从gmail或雅虎帐户“someone@gmail.com”到公司邮件帐户,如someone@companyname.net,它将无法正常工作。

<?php
    require_once __dir__.'/vendor/swiftmailer/swiftmailer/lib/swift_required.php';
    $password='nag';
    $transport = Swift_SmtpTransport::newInstance('localhost', 25);

    // Create the Mailer using your created Transport
    $mailer = Swift_Mailer::newInstance($transport);

    // Create a message
    $message = Swift_Message::newInstance()

      // Give the message a subject
      ->setSubject('Password Recovery')

      // Set the From address with an associative array
      ->setFrom(array('someone@company.net' => 'someone')) //change this mail id to gmail mail id

      // Set the To addresses with an associative array
      ->setTo(array('someone2@company.net' => 'someone')) //change this mail id to gmail mail id

      // Give it a body
      ->setBody('Below is your temporary password. Please make sure to login in immediately and change it to a password of your choice.\n'.$password);
    $result = $mailer->send($message);
    if($result){
      echo 'mail sent';
    }

我需要更改公司邮件服务器中的某些设置,或者我需要做其他事情请帮忙。

0 个答案:

没有答案