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;
}
任何幫助將是巨大的,謝謝!
什麼是發件人地址? –
dreamhost我發送電子郵件與快速郵件使用「sendmail」運輸,更容易 –