-
-
Notifications
You must be signed in to change notification settings - Fork 112
Sending emails from OFN
To properly configure OFN we need to be able to send emails from the application using an SMTP server. First, follow these steps below:
- Create an account in an SMTP service provider like SendGrid, Mandrill, etc.
- Register your domain in the SMTP provider following its specific documentation
Mail settings get automatically configured but some environmental variables need to be provided for it to work.
In the secrets.yml of your OFN instance, make sure you set the appropriate values for the variables mail_host, mail_port, smtp_username, smtp_password
. You can also configure variable mail_secure_connection
. These values will be provided by your SMTP service provider.
Once done, you need to provision your instance. This will make them available for the OFN app. When deploying from ofn-install
the db:seed
rake task will create and configure the mail settings with these values.
Note: Sidekiq needs to be restarted for these new values to be picked up. This is done as part of every app deployment.
You no longer can configure the basic mail settings in the UI. You can configure a few values in the UI:
-
Enable mail delivery
- you can use to enable/disable mail delivery in the app -
Send mails as
as your domain email likeno-reply@ofn.coop
-
Send copy of all emails
andIntercept email address
- Click "Send Test Email" on the top right corner
- A green banner on the top should appear communicating that a test email has been sent to the super admin email address (
ofn@example.com
by default in development) - Check your email to ensure that the email has been sent (check SPAM folder also)
Probably the SMTP settings are not correct or the SMTP provider is not able to send emails. Check the logs in the SMTP provider service for errors.
In /admin/mail_methods
, on the right of each mail method listed there is a "send test email" button with an ✉️ icon. This button will send an email to the super admin and it's useful to test the SMTP configuration BUT keep in mind that it will not send the email using delayed_job
. This is important since you may receive the test email but if for whatever reason the delayed_job
process is not running all the other email will not get sent. Check that the delayed_job
process is running.
Many email services will not allow registering email accounts for sub-domains like info@staging.ofn.coop
. The workaround is to use the same email account as in production (e.g. info@ofn.coop
) and use a different API key. In this way, you'll be able to send emails from the same address but filter the SMTP logs by API key.
Some server providers are known to block SMTP ports by default. If you see the email successfully sent from log/staging.log
or log/production.log
check out its security settings and allow connections to the SMTP ports. You might need to reboot the machine; that's the case for Scaleway.
Provisioning
Deployment
Sysadmin
External services
- Sending emails from OFN
- Email Deliverability
- SSL certificates
- Google Maps
- File storage
- Backups
- Server monitoring
- Issue reporting (Bugsnag)
Contributing