Rails mailer smtp configuration with gmail

957 Views Asked by At

So I am having trouble setting up this rails application(OpenProject, if it makes a difference). When I try the send a test mail in the openproject settings it displays a message in that the e-mail was sent but I don’t ever receive it at the address.

config/configuration.yml

production:
  delivery_method: :smtp
  smtp_settings:
    tls: true
    address: "smtp.gmail.com"
    port: '587'
    domain: "smtp.gmail.com"
    authentication: :plain
    user_name: "[email protected]"
    password: "your_password"

development:
  delivery_method: :smtp
  smtp_settings:
    tls: true
    address: "smtp.gmail.com"
    port: '587'
    domain: "smtp.gmail.com"
    authentication: :plain
    user_name: "[email protected]"
    password: "your_password"

test:
  delivery_method: :test

If I use:

telnet smtp.gmail.com 587

Trying 64.233.171.108...
Connected to gmail-smtp-msa.l.google.com.
Escape character is '^]'.
220 mx.google.com ESMTP r1sm2094806qam.42 – gsmtp

This leads me to think I can send to gmail but I cant receive from gmail. I have also tried all of the configurations such as port 25 and 456 as well as with SSL vs TLS and none. so I don't think it is just my ISP blocking the mail.

In my google settings → accounts and Import → add another email address you own Send mail through your SMTP server.

SMTP server: smtp.my_domain_name.com
        Port: 587
    Username: my_username_on_my_domain
    Password: passwd
        TLS (recommended)       ← (I have this selected)
        SSL

I get the message Couldn't reach server. Please double-check the server and port number.

I did run

netstat -a

If the results of that would be helpful let me know.

Any help would be greatly appreciated. Thanks.

1

There are 1 best solutions below

0
On

Unfortunately there is no any logs in your question. Please note:

  • Gmail Api Do not support sent email from different adress(protect from spam/spoof)
  • Rails can send email from self application and this options tell him what host use.

Consider config.action_mailer.raise_delivery_errors = true to debug your code and settins.