:address => "xsmtp.exmail.qq.com", :port => 25, #:domain => "mail.qq.com", :user_name => "[email protected]", :password => "c", :authentication => "plain" #:enable_starttls_auto => true
在邮箱设置里看到「smtp.exmail.qq.com(使用 SSL,端口号 465)」,但是又在腾讯的另一份文档中看到「向 xsmtp.exmail.qq.com(端口:25, 暂不支持 SSL)发起 Smtp 发信请求」。
我测试了 25 和 465,包括 ssl 开启与否,都无法发送邮件。在邮箱已发送中也看不到任何东西。不知道是不是因为 :auth 和 :domain 填的不正确?在网上搜了 :domain 说是只有 gmail 才需要填这个……
我用的 amazon 的 ses,是这样设置的
require 'net/smtp'
module Net
class SMTP
def tls?
true
end
end
end
希望对 lz 有帮助
address: smtp.exmail.qq.com port: 25 domain: exmail.qq.com authentication: :login user_name: "[email protected]" password: "c"
这个配置测试通过了:
if Rails.env.production? Rails.application.config.action_mailer.delivery_method = :smtp Rails.application.config.action_mailer.raise_delivery_errors = true
ActionMailer::Base.smtp_settings = { address: "smtp.exmail.qq.com", port: 465, user_name: "xxx@xxxx", password: "xxx", domain: "qq.com", authentication: :plain, ssl: true } end
这儿的文档没有讲 ssl 这个参数:http://api.rubyonrails.org/classes/ActionMailer/Base.html
config.action_mailer.smtp_settings = {
:address => "smtp.exmail.qq.com",
# :port => 587,
:port => 465,
:domain => 'exmail.qq.com',
:user_name => ENV['rrgene_username'],
:password => ENV['rrgene_password'],
:authentication => :login,
# :enable_starttls_auto => true
:ssl => true
}
ssl 对应 465 starttls 对应 587