简体   繁体   English

在Devise / Rails中使用无法传递的电子邮件进行注册

[英]Sign up with undeliverable email in Devise/Rails

i'm using Devise (3.4.1) in my application, but i have a problem with signing up process. 我在我的应用程序中使用Devise(3.4.1),但是我在注册过程中遇到问题。 When user attempts to sign up with valid but undeliverable email address, ActionMailer raises Net::SMTPFatalError exception and user see "Something went wrong" message. 当用户尝试使用有效但无法传递的电子邮件地址进行注册时,ActionMailer会引发Net :: SMTPFatalError异常,并且用户会看到“发生了错误”消息。

Is there any workaroud to have flash[:error] message on registration form instead of that? 是否有任何工作方法在注册表格上显示flash [:error]信息,而不是?

A few things you can do, the simplest is to put the sendmail call in a begin/rescue block, like so: 您可以做的几件事,最简单的方法是将sendmail调用放在begin / rescue块中,如下所示:

begin
  # Try to send mail
rescue Exception => e
  flash[:error] = e.message # OR a more readable error like "cannot deliver email"
  render :new
end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM