我使用ActionMailer
在我的應用程序中發送「聯繫我們」表單。
我使用山魈應用程序發送我的emails.These是我的設置:使用ActionMailer和Outlook/Mandrillapp SMTP服務器發送郵件
配置/環境/ development.rb
config.action_mailer.perform_deliveries = true
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => "smtp.mandrillapp.com",
:port => 587,
:enable_starttls_auto => true,
:user_name => 'SMTP username i.e Mandrill a/c username',
:password => 'API key for development',
:domain => 'example.com',
:authentication => 'plain'
}
配置/環境/ production.rb
我有刪除該行
config.action_mailer.raise_delivery_errors = true
並更改了生產密碼 - 即用於生產的Mandrill應用程序API密鑰。
應用程序/郵寄/ contactus_mailer.rb
class ContactusMailer < ActionMailer::Base
default :from => "[email protected]"
default :to => "[email protected]"
def new_message(message)
@message = message
mail(:subject => "[WebsiteName] #{message.name + " - " + message.email}")
end
end
自定義域上述帳戶的有效性 - example.com
以上的電子郵件帳戶,即[email protected]
& [email protected]
的供應方式以及充分功能。以上帳戶是在Outlook.com中設置的,我還對我的域名example.com進行了兩次MX記錄檢查,域名設置對我的域名爲「有效」。作爲證據,我可以從帳戶中發送/接收兩個帳戶的電子郵件。
開發和生產環境日誌:
當我使用這兩種環境聯繫我們表格,報告的ActionMailer沒有錯誤,併成功地重定向到主頁。
Started POST "/contact" for 127.0.0.1 at 2013-08-18 12:35:37 +0530
Processing by MessagesController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"UNgMrA04yk4sIbqtXjlLvLvDINgrBT5eP0wMSRYNgPs=", "message"=>{"name"=>"Dummy name", "email"=>"[email protected]", "content"=>"Random body"}, "commit"=>"Send Message"}
Rendered contactus_mailer/new_message.text.erb (0.5ms)
Sent mail to [email protected] (2679ms)
Date: Sun, 18 Aug 2013 12:35:38 +0530
From: [email protected]
To: [email protected]
Message-ID: <[email protected]l>
Subject: [WebsiteName] Dummy name - [email protected]
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: 7bit
Name: Dummy name
Email: [email protected]
Body: Random body
Redirected to http://localhost:3000/
Completed 302 Found in 3841ms (ActiveRecord: 0.0ms)
山魈應用API日誌生產環境:
完整的請求:
{
"from_email": null,
"from_name": null,
"async": false,
"key": "API key for production",
"raw_message": "Received: from example.com (unknown [23.20.245.109])\n\t(Authenticated sender: [email protected])\n\tby ip-10-31-147-25 (Postfix) with ESMTPSA id 6811A151A064\n\tfor <[email protected]>; Sun, 18 Aug 2013 08:19:11 +0000 (UTC)\nDate: Sun, 18 Aug 2013 08:19:11 +0000\nFrom: [email protected]\nTo: [email protected]\nMessage-ID: <[email protected]mail>\nSubject: [WebsiteName] Dummy name - [email protected]\nMime-Version: 1.0\nContent-Type: text/plain;\n charset=UTF-8\nContent-Transfer-Encoding: 7bit\n\nName: Dummy name\n\nEmail: [email protected]\n\nBody: Random body",
"to": [
"[email protected]"
]
}
完全響應:
[
{
"email": "[email protected]",
"status": "rejected",
"_id": "9c9f88c588ee4f369437b8dd5d531c8c",
"reject_reason": "soft-bounce"
}
]
山魈應用API日誌開發環境:
Full Request for development env。與生產環境相似。但是,在開發過程中,迴應是不同的。
完全響應:
[
{
"email": "[email protected]",
"status": "sent",
"_id": "e67f31f893a84ecdb0ed2438e5741ce1",
"reject_reason": null
}
]
注:我不是在開發和生產環境讓我的賬戶[email protected]
電子郵件。
查詢:
爲什麼我會得到拒絕的狀態和軟彈拒絕的理由進行生產ENV,而對於發展它說發送狀態,並沒有拒絕的理由。
爲什麼我在這兩種情況下都沒有收到郵件?
P.S.
最初,我沒有使用Mandrill app
,並且使用smtp.live.com
作爲我的SMTP服務器以及我的no [email protected]
憑據,但這並未奏效。 然後,我在谷歌上進行了一些挖掘後轉向了Mandrill。
如果有人可以幫助Outlook郵件設置,這將是同樣好。這樣,Mandrill就完全不需要了。
我正在使用此確切設置,並且出現ssl錯誤。你有沒有ssl證書?爲你的域名? –
@TommyAdey:沒有。我沒有SSL證書。你能否請你多解釋一下你的問題。 –
Mine說OpenSSL :: SSLError - SSL_read:錯誤的版本號。我一直在嘗試幾天,但它仍然無法正常工作。我也嘗試過:openssl_verify_mode =>'none'。 –