Reputation: 2866
I'm having an impossible time trying to figure out how to setup email in development with sendgrid, and Actionmailer.
I've read a bunch of varying things and I keep getting different errors. Right now I get this one:
Net::SMTPFatalError in UsersController#create
550 Cannot receive from specified address <[email protected]>: Unauthenticated senders not allowed
What do I need to put in development.rb so that the activation email is sent?
config.action_mailer.raise_delivery_errors = true
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
config.action_mailer.perform_deliveries = true
config.action_mailer.delivery_method = :smtp
config.action_mailer.smtp_settings = {
:address => 'smtp.sendgrid.net',
:port => '587',
:authentication => :plain,
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:domain => 'localhost:3000',
:enable_starttls_auto => true
}
2
Upvotes: 1
Views: 3373
Reputation: 2866
I used the rails cast tutorial here because I couldn't get it to work with sendgrid: http://railscasts.com/episodes/61-sending-email-revised?view=asciicast
Upvotes: 0
Reputation: 24337
It looks like you just need to set the SENDGRID_USERNAME and SENDGRID_PASSWORD environment variables. You can set these temporarily in your terminal by running the following commands:
export SENDGRID_USERNAME=<your sendgrid username>
export SENDGRID_PASSWORD=<your sendgrid password>
When you restart your terminal you will lose these settings. To make them persistent add those same commands to your ~/.bash_profile
Upvotes: 3