使用Godaddy邮件与Rails 3的SMTP设置

时间:2011-04-29 06:36:22

标签: ruby-on-rails ruby ruby-on-rails-3 actionmailer

如何使用Godaddy邮件在初始化程序文件中设置SMTP设置?

2 个答案:

答案 0 :(得分:11)

无耻地从这篇文章中摘录:http://pilotoutlook.wordpress.com/2008/10/13/setup-email-in-ruby-on-rails-using-godaddysmtp/

打开ROOT/config/environment.rb文件 对于sendmail,请添加以下行 -

ActionMailer::Base.delivery_method = :sendmail
ActionMailer::Base.smtp_settings = {
:domain  => ‘www.example.com’
}

对于Godaddy,请添加以下内容 -

ActionMailer::Base.delivery_method = :smtp
ActionMailer::Base.smtp_settings = {
:address => ‘smtpout.secureserver.net’,
:domain  => ‘www.example.com’,
:port      => 80,
:user_name => ‘johndoe@example.com’,
:password => ‘yourpassword’,
:authentication => :plain
}

保存并重新启动您的网络服务器。你们都准备好了。

请记住,您每天只能从Godaddy发送300封电子邮件,因此如果您需要发送更多电子邮件,则必须使用sendmail或其他解决方案。

请注意,端口未设置为25 - 这是故意的。 GoDaddy的电子邮件服务器配置为使用多个端口,以防25被阻止。

答案 1 :(得分:5)

# config/environments/production.rb
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address => 'smtpout.secureserver.net',
  :domain  => 'www.example.com',
  :port      => 80,
  :user_name => 'johndoe@example.com',
  :password => 'yourpassword',
  :authentication => :plain
}