Configure SMTP for outbound emails
Google Cloud Platform doesn’t allow SMTP traffic through default ports: 25, 465, 587. Check Google cloud documentation to learn how to use a VPN to bypass these restrictions or use a different port for sending emails from your application.
First, configure the email settings using SMTP. In your Mahara site, navigate to “Administration -> Configure Site -> Site options -> Email Settings”. There, set the parameters of your account to use SMTP and send emails.
Verify that you can send emails from that SMTP server BEFORE you even bother trying to test any emails from your Mahara site. When you create a mailbox on your hosting service’s email server, you specified a user name and a password. Using your service’s Webmail or other similar service, log into your SMTP mailbox and send a test email to anther email account. Once you are able to do that successfully, only then proceed with the following.
Your emails are not sent automatically from your Mahara site. Instead, they are queued and sent at various times by a built-in cron system. The instructions have already covered how to set up the cron on your server to hit your Mahara site’s cron system every minute, which in turn triggers its own built-in cron program. Since this is a new install, you may not be sure if cron is working correctly. If you have email problems, it can be confusing to determine which is at fault (the SMTP, the cron or both). You can first try manually hitting your Mahara’s cron system by typing the following:
/usr/bin/curl -s http://YOUR-DOMAIN.COM/lib/cron.php
A typical cron system on a hosting service can be edited with a command such as:
EDITOR=nano crontab -e
That will bring up your cron file in the easy-to-use nano editor, which may start out empty. If that does not work, check with your hosting service to find out their specific procedure. If that or similar command gets you into an editor, type the following line:
* * * * * /usr/bin/curl -s http://YOUR-DOMAIN.COM/lib/cron.php
Save the file.
Now that it appears that a working cron is configured, the best way to test the Mahara email is by sending yourself a message through the “Contact us” form. The reason is that it is triggered very quickly by Mahara’s cron system, and should therefore be sent to your admin user’s email address within a minute or so. Note that other emails from the system, like notifications on new forum posts, can take much longer to be triggered by Mahara’s cron.
If this does not work even after a reasonable time, check these items:
- Make sure your admin email account is working. Send it a test message from a Gmail account or some other account.
- If it is working, check the junk or spam folders for your “Contact us” messages, as they may have been flagged before they got to your inbox.
- While logged in as an admin user, click the “Profile -> Settings -> Notifications” menu. This should have a copy of all incoming messages of all types for the admin user. See if your messages appear correctly.
- Begin checking and changing the settings for the SMTP and the cron. Manually trigger the cron after each setting change, then retest the “Contact us” form. Eecheck your email inbox, spam, and also the “Notifications” log. Repeat until your figure out the problem.
- If you work systematically, making notes as you go through each combination you have tried, it will be easier to debug the problem and/or ask for help in the forums. In the forums, give enough detail of your settings and tests, but do not compromise your passwords.
To configure the application to use other third-party SMTP services for outgoing email, such as SendGrid, refer to the FAQ.