Reputation: 1560
I have my first mailer attempt at hand. Here is my mailer...
class UserMailer < ActionMailer::Base
default from: 'http://my-heroku-prename.herokuapp.com'
def welcome_email(current_user)
@user = current_user
@url = 'http://my-heroku-prename.herokuapp.com/'
mail(to: @user.email, subject: 'Welcome to My Awesome Site')
end
end
If have this line at the end of my UserController create block
UserMailer.welcome_email(@user).deliver
I my production.rb looks like this
config.action_mailer.raise_delivery_errors = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.default_url_options = { :host => 'my-heroku-prename.heroku.com' }
ActionMailer::Base.smtp_settings = {
:address => "smtp.sendgrid.net",
:port => 587,
:user_name => ENV['my_actually_sendgrid_username'], #should I just put the default here?
:password => ENV['my_actually_sendgrid_pw'],
:domain => ENV['heroku.com'],
:authentication => plain
There error I get is
Net::SMTPFatalError (553 Parse error at ':' of ('<http://me-heroku-prename.herokuapp.com>', [':', '//my-heroku-prename', '.', 'herokuapp', '.', 'com'])
I've searched this 553 parse error but couldn't find anything... Is this just a synxtax thing?
Thanks in advance for the help.
Upvotes: 0
Views: 475
Reputation: 3986
Your default from:
should be an email address rather than a URL. This specifies the address that will appear as the from in emails sent.
You can modify the from on a per message basis by putting it in your Mailer's methods.
Upvotes: 1