Rails 使用 action mailer 报错。

zzjkevin · April 01, 2014 · Last by zzjkevin replied at April 01, 2014 · 2387 hits

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

def send_mail(params = {})
@url = 'http://example.com/login'
mail( :subject => 'abcAAAAAAAASDFADSFADSFADSFDASFASDF',
:to => "@qq.com",
:from => '@126.com',
:date => Time.now
)
end
end

定义了一个方法,然后在我的一个控制器里面,UserMailer.send_mail(nil).deliver 发邮件。

environment.rb 里面的配置如下:

config.action_mailer.delivery_method = :smtp config.action_mailer.smtp_settings = { address: 'smtp.126.com', port: 25, domain: '126.com', user_name: '[email protected]', password: 'xxxxx', authentication: 'login', enable_starttls_auto: true }

但是最后,会报错: Missing template user_mailer/send_mail with "mailer". Searched in: * "user_mailer"

建一个 app/views/user_mailer/send_mail.text.erb .. 错误提示都已经告诉你了啊

You need to Sign in before reply, if you don't have an account, please Sign up first.