我使用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'。 –