2017-04-01 45 views
0

我想用SwiftMailer和SMTP发送电子邮件。 SMTP服务器是标准的Dreamhost设置。我只在使用未托管在Dreamhost上的电子邮件时遇到问题。例如,如果我使用[email protected]作为发件人电子邮件地址,我将不会遇到任何问题,并且会发送电子邮件。但是,如果我用[email protected]我会得到以下错误:不允许使用SMTP Dreamhost的SwiftMailer发件人域名?

Expected response code 250 but got code "550", with message "550 5.7.1 Sender domain not allowed. Please read: http://dhurl.org/20b D157 "

我的电子邮件功能如下:

/** 
* 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(['[email protected]' => '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; 
} 

任何帮助将是巨大的,谢谢!

+0

什么是发件人地址? –

+0

dreamhost我发送电子邮件与快速邮件使用“sendmail”运输,更容易 –

回答

2

尝试不回复@ whatever-server-you-are-on &使用回复标题的发件人地址?