【问题标题】:Symfony 1.4: email configurationSymfony 1.4:电子邮件配置
【发布时间】:2014-09-24 21:12:25
【问题描述】:

我正在尝试从运行 Symfony 1.4 的服务器发送一封电子邮件。

我有通常的基本邮件服务器设置,服务器名称为mail.tixxit.com.au,端口为25。我的factories.xml 中有这个配置:

  mailer:
    param:
      transport:
        class: Swift_SmtpTransport
          param:
            host:       mail.tixxit.com.au
            port:       25
            encryption: ssl # Not sure on this but have tried "tls" too
            username:   myaccount@tixxit.com.au
            password:   mypassword

然后我在我的一个操作中有一个基本的发送代码:

        $this->getMailer()->composeAndSend(
            "myaccount@tixxit.com.au",
            "anotheraccount@gmail.com",
            "Message title",
            "Message content"
        );

从我在其他文档中看到的内容来看,这应该是我在 PHP 中使用 Symfony 从我的服务器发送电子邮件所需要做的一切,但这不起作用。发送代码没有给出任何错误,我可以从我的网络服务器正常访问mail.tixxit.com.au 服务器,我的凭据绝对正确,并且我已经在我的电子邮件托管公司的支持下确认这应该可以工作并且不需要配置他们这边允许这样。

但是我的邮件没有发送出去。我在factories.xml 中尝试了很多不同的设置,但没有任何效果。它似乎发送,但没有任何东西到达anotheraccount@gmail.com。我已经在我的本地机器和我的网络服务器上尝试过这个并且得到了相同的结果。

我在这里缺少什么?我需要什么Symfony/PHP/server/mail 帐户设置才能真正完成这项工作?我应该在 Symfony 内容之前设置一些基本的其他配置来允许我发送吗?

【问题讨论】:

    标签: php email symfony-1.4


    【解决方案1】:

    我找不到这个问题的答案。似乎没有任何效果。我放弃并使用了自然的 Swift 类,例如:

            $transport = Swift_SmtpTransport::newInstance('mail.tixxit.com.au', 25)
                ->setUsername('myaccount@tixxit.com.au')->setPassword('mypassword');
    
            $mailer = Swift_Mailer::newInstance($transport);
    
            $message = Swift_Message::newInstance("Message title")
                ->setFrom(array('myaccount@tixxit.com.au' => 'App'))
                ->setTo(array('anotheraccount@gmail.com'));
    
            $message->setBody("Message content.");
    
            if ($mailer->send($message, $errors)) {
                $success = true;
            }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-11
      相关资源
      最近更新 更多