Linux下使用sendmail的设置
[code]
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t -f no-reply@anyhost.com'
}
[/code]
一定要注意ActionMailer::Base.delivery_method = :sendmail,默认好像是:smtp如果不设置使用sendmail会发不出信的。
使用smtp的设置
[code]
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "mail.anyhost.com",
:port => 25,
:domain => "anyhost.com",
:authentication => :login,
:user_name => "youraccount",
:password => "yourpassword",
}
[/code]
[code]
ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.sendmail_settings = {
:location => '/usr/sbin/sendmail',
:arguments => '-i -t -f no-reply@anyhost.com'
}
[/code]
一定要注意ActionMailer::Base.delivery_method = :sendmail,默认好像是:smtp如果不设置使用sendmail会发不出信的。
使用smtp的设置
[code]
ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => "mail.anyhost.com",
:port => 25,
:domain => "anyhost.com",
:authentication => :login,
:user_name => "youraccount",
:password => "yourpassword",
}
[/code]
本文介绍如何在Linux环境下使用Rails应用配置Sendmail及SMTP发送邮件。详细讲解了通过设置ActionMailer基类来实现使用Sendmail或SMTP两种不同方式发送邮件的方法。
32

被折叠的 条评论
为什么被折叠?



