2011-09-18 231 views
0

我跟着THIS关于如何使用RoR发送电子邮件的网站。运行服务器和调用该方法后,它显示在控制台:使用RoR发送电子邮件

Rendered user_mailer/welcome_email.html.erb (1.0ms) 
Rendered user_mailer/welcome_email.text.erb (1.0ms) 

Sent mail to [email protected] (1128ms) 
Date: Sun, 18 Sep 2011 13:44:49 +0530 

From: [email protected] 

To: [email protected] 

Message-ID: <[email protected]> 

Subject: Welcome to My Awesome Site 

Mime-Version: 1.0 

Content-Type: multipart/alternative; 

boundary="--==_mimepart_4e75a878df4a2_ed81feda646659d"; 

charset=UTF-8 

Content-Transfer-Encoding: 7bit 
....... 

,但我没有收到在我的收件箱的任何电子邮件。可能有人请告诉我什么是这里的问题...

回答

1

我想你还没有:

config.action_mailer.perform_deliveries = true 
在development.rb文件

+0

感谢apneadiving ...但现在我收到一个错误:'Errno :: ECONNREFUSED(无法建立连接,因为目标机器主动拒绝它 - connect(2)):'on the line in the controller我称之为“交付”。你能告诉我任何解决办法吗? –

+0

你有什么错误? – apneadiving

+0

我在我的登录控制器中调用递送方法。我按如下方式调用递送方法:'UserMailer.welcome_email(user).deliver'。如果我调用递送方法,我得到错误:'Errno :: ECONNREFUSED(由于目标机器主动拒绝连接,所以无法连接 - connect(2)):app/controllers/login_controller.rb:16:登录',但是如果我评论它,那么登录成功按需要。 –

1

前段时间我玩过Ryan screencast on Action Mailer,一切都很顺利。一探究竟!

+0

+1为好的建议 – apneadiving

+0

那页告诉我们如何使用gmail的SMTP服务器来发送邮件的权利?我在WEBrick上部署的本地服务器上运行应用程序。我在帖子中提到的例子没有提到配置ActionMailer :: Base.smtp_settings ... –

+0

我把下面的设置放在我的environment.rb文件中:'ActionMailer :: Base.smtp_settings = { :address => “smtp.gmail.com”, :端口=> 587, :认证=>:登录, :USER_NAME => “我的Gmail用户名”, :密码=> “我的Gmail PWD” } 的ActionMailer :: Base.delivery_method =:smtp'它工作。但是,我们可以做到这一点,而不使用Gmail的SMTP服务器发送邮件? –