Troubleshooting Email
Manually Test Email Delivery
The quickest way to get to the root cause of SMTP issues is to try and send an email from the application console. On error, this will dump out the exact issue to be fixed.
Enable Error Reporting
Make sure to enable raise_delivery_errors
in your settings.yml (or PWP__MAIL__RAISE_DELIVERY_ERRORS=true
).
mail:
raise_delivery_errors: true
Send an Email from the Application Console
Note: The following commands are available since v1.39.8. Make sure to run that version or later to before attempting.
Open a shell into the Docker container and start the application console:
docker exec -it <containerId> /bin/bash
./bin/pwpush console
Run this code snippet to manually send an email. Replace the destination email address with your own:
TestMailer.send_test_email("user@example.com").deliver_now
On error, output will be displayed. This should identify where the issue is. Please include this in any issue that you file.
On success, you should receive an email in your inbox.
Example Success Output
╰─ ./bin/pwpush console
Password Pusher Version: 1.39.8
Loading development environment (Rails 7.1.3.2)
[1] pry(main)> TestMailer.send_test_email('user@domain.com').deliver_now
--> Configured FROM: address: '"Password Pusher" <pglombardo@pwpush.com>'
--> raise_delivery_errors is set to true in the configuration. This will raise an error if the email fails to send.
--> Attempting to send a test email to user@domain.com...
--> It seems that the Email sent successfully! Check destination inbox for the test email.
--> If you see an error, please paste this output into a GitHub issue for help.
--> Make sure that no sensitive data is included.
--> https://github.com/pglombardo/PasswordPusher/issues/new/choose
TestMailer#send_test_email: processed outbound mail in 15.6ms
Delivered mail 6615a15c85a96_6c3b170c6251@The-Studio.local.mail (5413.4ms)
Date: Tue, 09 Apr 2024 22:13:16 +0200
From: Password Pusher <pglombardo@pwpush.com>
To: user@domain.com
Message-ID: <6615a15c85a96_6c3b170c6251@The-Studio.local.mail>
Subject: Test Email from Password Pusher
Mime-Version: 1.0
Content-Type: text/plain;
charset=UTF-8
Content-Transfer-Encoding: quoted-printable
=E2=AD=90 If you are reading this, sending email works! =E2=AD=90=
=> #<Mail::Message:25660, Multipart: false, Headers: <Date: Tue, 09 Apr 2024 22:13:16 +0200>,
<From: "Password Pusher" <pglombardo@pwpush.com>>, <To: user@domain.com>,
<Message-ID: <6615a15c85a96_6c3b170c6251@The-Studio.local.mail>>,
<Subject: Test Email from Password Pusher>, <Mime-Version: 1.0>,
<Content-Type: text/plain>, <Content-Transfer-Encoding: quoted-printable>>
[2] pry(main)>
Known Working Configurations
GMail
mail:
raise_delivery_errors: true
smtp_address: smtp.gmail.com
smtp_port: 587
smtp_authentication: plain
smtp_user_name: <your gmail email>
smtp_password: <Application-specific password>
smtp_enable_starttls_auto: true
smtp_open_timeout: 10
smtp_read_timeout: 10
GMail requires an application specific password. If you try to use your account password, an error is raised:
Net::SMTPAuthenticationError: 534-5.7.9 Application-specific password required.
See Google: Sign in with app passwords.
Microsoft 365 / Exchange Online
Contributed by @mathsyx69 in #2013
The authentication method “plain” isn’t supported by smtp.office365.com but the method “login” is supported.
mail:
raise_delivery_errors: true
smtp_address: 'smtp.office365.com'
smtp_user_name: 'm365 email'
smtp_password: 'm365 password'
#smtp_domain: 'outlook.com' //optional it work with or without it
smtp_port: '587'
smtp_authentication: 'login'
smtp_starttls: true
smtp_enable_starttls_auto: true
smtp_open_timeout: 10
smtp_read_timeout: 10
mailer_sender: '"Password Pusher" <m365 email>'
Sendgrid
mail:
raise_delivery_errors: true
smtp_address: smtp.sendgrid.net
smtp_port: 587
smtp_authentication: plain
smtp_user_name: apikey
smtp_password: <your password>
smtp_starttls: true
smtp_enable_starttls_auto: true
smtp_open_timeout: 10
smtp_read_timeout: 10
mailer_sender: '"Your Name" <name@domain.com>'
Other
Email configuration is unfortunately more problematic than I like given the range of setups, email servers, firewalls and more. Thus far, there has been no easy answer to just make it work for everyone (yet).
If you’ve gone through this page and are still having issues with email, please search the issues to see the solutions others have found.
Viewing the SMTP Settings
To better diagnose email related issues, you can open a console in the pwpush container and run the following to dump the configuration:
docker exec -it <containerId> /bin/bash
./bin/pwpush console
Rails.application.config.action_mailer.smtp_settings
That last command will output the Mail settings. Validate that the settings are correct. If you file an issue, please include this information (with sensitive information removed).