ruby-on-rails – Rails 3.2.1动作管理器设置
发布时间:2020-12-17 02:01:49 所属栏目:百科 来源:网络整理
导读:我在注册时设置ActionMailer有困难: 配置/初始化/为setup_mail.rb ActionMailer::Base.smtp_settings = { :address = "smtp.gmail.com",:port = "587",:domain = "mail.gmail.com",:user_name = "my_gmail_user_name",:password = "my_gmail_pw",:authentic
我在注册时设置ActionMailer有困难:
配置/初始化/为setup_mail.rb ActionMailer::Base.smtp_settings = { :address => "smtp.gmail.com",:port => "587",:domain => "mail.gmail.com",:user_name => "my_gmail_user_name",:password => "my_gmail_pw",:authentication => "plain",:enable_starttls_auto => true } ActionMailer::Base.default_url_options[:host] = "localhost:3000" Mail.register_interceptor( DevelopmentMailInterceptor ) if Rails.env.development? users_controller.rb def create @user = User.new( params[:user] ) respond_to do |format| if @user.save UserMailer.welcome_email( @user ).deliver format.html{ redirect_to( @user,:notice => 'Account successfully created.' ) } format.json{ render :xml => @user,:status => :created,:location => @user } else format.html { render :action => "new" } format.xml { render :xml => @user.errors,:status => :unprocessable_entity } end end 应用程序/邮寄者/ user_mailer.rb class UserMailer < ActionMailer::Base default :from "no-reply@myapp.com" def welcome_email( user ) @user = user @url = "http://localhost:3000/login" mail( :to => user.email,:subject => 'Welcome to app' ) end end LIB /为development_mail_interceptor.rb class DevelopmentMailInterceptor def self.delivering_email(message) message.subject = "#{message.to} #{message.subject}" message.to = "mydump@email.com" end end 我没有收到任何发送到DevelopmentMailInterceptor中的转储电子邮件的电子邮件. 解决方法
gmail是肛门!无论如何你可以使用不同的smtp主机吗?我认为,由于过于激进的垃圾邮件检测,他们会默默拒绝他们认为是“潜在垃圾邮件”的粉丝请求.您的案例中的潜在垃圾邮件意味着来自“mail.gmail.com”以外的地址的电子邮件,在您的情况下为“email.com”.
我认为使用gmail作为Rails应用程序的SMTP主机是一个失败的主张,我使用godaddy.com(smtpout.secureserver.net)为我的rails应用程序,并没有问题. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |