38
我使用的mail
宝石的Ruby https://github.com/mikel/mail如何使用Ruby的邮件gem通过smtp发送电子邮件?
如何通过SMTP服务器发送电子邮件?我如何指定地址和端口?我应该使用哪些Gmail设置?
github上的README
只给出了本地服务器发送的例子。
我使用的mail
宝石的Ruby https://github.com/mikel/mail如何使用Ruby的邮件gem通过smtp发送电子邮件?
如何通过SMTP服务器发送电子邮件?我如何指定地址和端口?我应该使用哪些Gmail设置?
github上的README
只给出了本地服务器发送的例子。
从http://lindsaar.net/2010/3/15/how_to_use_mail_and_actionmailer_3_with_gmail_smtp
要通过Gmail发送出去,你需要配置Mail::SMTP
类有正确的价值观,所以尝试了这一点,开拓IRB并键入以下内容:
require 'mail'
options = { :address => "smtp.gmail.com",
:port => 587,
:domain => 'your.host.name',
:user_name => '<username>',
:password => '<password>',
:authentication => 'plain',
:enable_starttls_auto => true }
Mail.defaults do
delivery_method :smtp, options
end
最后一个块调用Mail.defaults
,它允许我们为从现在开始创建的所有邮件对象设置全局交付方法。高级用户提示,您不必使用全局方法,您可以直接在任何个人对象上定义delivery_method,并且每封电子邮件都有不同的传送代理,如果您正在构建具有多个用户且具有不同服务器的应用程序处理他们的邮件。
Mail.deliver do
to '[email protected]'
from '[email protected]'
subject 'testing sendmail'
body 'testing sendmail'
end
谢谢西蒙娜工作 –
Upvote。非常感谢Mikel。 – orde
我收到以下错误:'/usr/local/rvm/rubies/ruby-1.9.3-p327/lib/ruby/1.9.1/net/smtp.rb:960:in'check_auth_response':534- 5.7.14
janosrusiczki