【问题标题】:SwiftMailer sender domain not allowed using SMTP Dreamhost?SwiftMailer 发件人域不允许使用 SMTP Dreamhost?
【发布时间】:2017-08-26 09:41:40
【问题描述】:

我正在尝试使用 SwiftMailer 和 SMTP 发送电子邮件。 SMTP 服务器是标准的 Dreamhost 设置。我只有在使用不是在 dreamhost 上托管的电子邮件时才会遇到问题。例如,如果我使用contact@joescotto.net 作为发件人电子邮件,我将没有问题并且电子邮件将发送。但是,如果我使用contactjoescotto@gmail.com,我会收到以下错误:

预期响应代码为 250,但得到代码“550”,消息“550 5.7.1 不允许发件人域。请阅读:http://dhurl.org/20bD157”

我的邮箱功能如下:

/**
 * Sends an email
 * @param  string $name    Sender name
 * @param  string $subject Sender subject
 * @param  string $email   Sender email
 * @param  string $message Sender message
 * @return bool            True if sent, otherwise false
 */
public static function sendMessage($name, $subject, $email, $message) {
    // Create and setup the transport
    $transport = Swift_SmtpTransport::newInstance($GLOBALS['config']['smtp']['host'], $GLOBALS['config']['smtp']['port'])
        ->setUsername($GLOBALS['config']['smtp']['username'])
        ->setPassword($GLOBALS['config']['smtp']['password']);

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

    // Create a message
    $message = Swift_Message::newInstance($subject)
        ->setFrom([$email => $name])
        ->setTo(['contact@joescotto.net' => 'Joe Scotto'])
        ->setBody($message);

    // Try to send the message
    if (!$mailer->send($message)) {
        return false;
    }

    // Set email timeout cookie
    setcookie("emailTimeout", true, time() + (60 * 5), '/');

    // Return true on sucessful send
    return true;
}

任何帮助都会很棒,谢谢!

【问题讨论】:

  • 发件人地址是什么?
  • 在 Dreamhost 上,我使用“sendmail”传输方式通过 swift mailer 发送电子邮件,更轻松

标签: php email smtp swiftmailer dreamhost


【解决方案1】:

尝试 no-reply@whatever-server-you-are-on 并使用回复标头作为发件人地址?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-05-14
    • 2014-08-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多