Search code examples
ruby-on-railsrubyemailrack-pow

Why am I unable to send an email with pow?


I have a rails project which sends an email using an ActionMailer. This seems to work fine with 'rails server' on localhost:3000 but when I use pow, I get authentication error messages from the smtp server. I'm guessing this has something to do with environment variables. Here is the config code

 config.action_mailer.smtp_settings = {
 address: "smtp.gmail.com",
 port: 587,
 domain: "railscasts.com",
 authentication: "plain",
 enable_starttls_auto: true,
 user_name: ENV["GMAIL_USERNAME"],
 password: ENV["GMAIL_PASSWORD"]
}

I'm on Mountain Lion.

Thanks


Solution

  • Pow loads environment variables from checking two files in the application root

    1. .powrc
    2. .powenv

    I created the .powrc file using the touch command, then added my environment variables

    export GMAIL_USERNAME=username
    export GMAIL_PASSWORD="my password"
    

    I then restarted the worker for the app this way:

    touch tmp/restart.txt
    

    E-mails now work!