This error because of the default hash in action mailer. Default hash is from address to mailers.
for below mailer it don't have any default mail address. But my case, i created a application mailer is inheriting from ActionMailer::Base.
class ApplicationMailer < ActionMailer::Base
default from: "xxxxxxxxx@gmail.com"
layout 'mailer'
end
class PostCreate < ActionMailer::Base
def user_post(user)
@user = user
@post = @user.posts.last
mail to: @user.email, subject: "Your post created #{@post.title}"
end
end
Two ways solve this kind of errors:
for below mailer it don't have any default mail address. But my case, i created a application mailer is inheriting from ActionMailer::Base.
class ApplicationMailer < ActionMailer::Base
default from: "xxxxxxxxx@gmail.com"
layout 'mailer'
end
class PostCreate < ActionMailer::Base
def user_post(user)
@user = user
@post = @user.posts.last
mail to: @user.email, subject: "Your post created #{@post.title}"
end
end
Two ways solve this kind of errors:
- Above case replace ActionMailer::Base from the PostCreate to ApplicationMailer
- Add default mailer hash to PostCreate file.
Comments
Post a Comment