Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 为什么不是';t rails动作邮件器是否正常工作?页面不是';不要渲染任何错误_Ruby On Rails_Actionmailer - Fatal编程技术网

Ruby on rails 为什么不是';t rails动作邮件器是否正常工作?页面不是';不要渲染任何错误

Ruby on rails 为什么不是';t rails动作邮件器是否正常工作?页面不是';不要渲染任何错误,ruby-on-rails,actionmailer,Ruby On Rails,Actionmailer,我试图使用action mailer在用户注册时向其发送一封简单的电子邮件,但action mailer似乎根本没有发送任何电子邮件。有趣的是,重定向代码工作正常,页面在本地主机上正确呈现,但在heroku上它会说“对不起,出了问题” 以下是我在用户控制器中所做的操作: if @user.save UserMailer.welcome_email(@user).deliver flash[:success] = "Congratulations, you've cre

我试图使用action mailer在用户注册时向其发送一封简单的电子邮件,但action mailer似乎根本没有发送任何电子邮件。有趣的是,重定向代码工作正常,页面在本地主机上正确呈现,但在heroku上它会说“对不起,出了问题”

以下是我在用户控制器中所做的操作:

if @user.save    
     UserMailer.welcome_email(@user).deliver
     flash[:success] = "Congratulations, you've created your band app account!"
     redirect_to root_path
else
  render 'new'
end
控制器中提到的欢迎电子邮件方法:

class UserMailer < ActionMailer::Base
  default from: "admin@something.com"

  def welcome_email(user)
    @user = user
    @url = signin_path
    mail(to: user.email, subject: "Your band app account has been created" )
  end
end
class UserMailer
最后是电子邮件视图的代码(app/views/user\u mailer中的welcome\u email.html.erb:

<!DOCTYPE html>
<html>
  <body>
    <h1>Welcome to the band app, <%= @user.name %></h1>
    <p>
      Your band app account has been created.<br/>
    </p>
    <p>
      To login to the site, just follow this link: <%= @url %>.
    </p>
    <p>Thanks for joining and have a great day!</p>
  </body>
</html>

欢迎使用乐队应用程序,

您的band应用程序帐户已创建。

要登录到该站点,只需遵循以下链接:。

感谢您的加入,祝您度过愉快的一天


提前感谢您的帮助!

您是否设置了
环境
文件

正如这里所说,您应该使用以下设置设置
development.rb
或与您正在使用的环境相关的文件:

config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
  :address              => "smtp.gmail.com",
  :port                 => 587,
  :domain               => 'baci.lindsaar.net',
  :user_name            => '<username>',
  :password             => '<password>',
  :authentication       => 'plain',
  :enable_starttls_auto => true  }
config.action\u mailer.delivery\u method=:smtp
config.action\u mailer.smtp\u设置={
:address=>“smtp.gmail.com”,
:端口=>587,
:domain=>“baci.lindsaar.net”,
:user_name=>“”,
:密码=>'',
:身份验证=>“普通”,
:enable_starttls_auto=>true}

我知道链接上说这是Gmail的一个例子,但你必须在你的ENV文件上设置这些配置,比如你正在使用的电子邮件(
:user\u name
)、密码等等。

对不起,我是一个完全的noob,我应该设置用户名为什么?是我的谷歌帐户还是访问我正在制作的应用程序的用户名?