Configure SMTP for outbound emails
- Google Cloud Platform doesn’t allow SMTP traffic through port 25. Check Google cloud documentation to learn how to use a different port for sending emails from your application.
To configure SMTP settings using an external SMTP server, follow these steps:
Add the lines indicated below to the /opt/bitnami/apps/silverstripe/htdocs/mysite/_config.php file and update the placeholders to reflect the settings for the SMTP server:
SmtpMailer::set_conf(array( 'default_from' => array( 'name' => 'SMTP_NAME', 'email' => 'SMTP_USER' ), 'charset_encoding' => 'utf-8', 'server' => 'SMTP_HOSTNAME', 'port' => SMTP_PORT, 'secure' => 'METHOD', 'authenticate' => true, 'user' => 'SMTP_USER', 'pass' => 'SMTP_PASSWORD', 'debug' => 0, 'lang' => 'en' ));
Here’s an example using Gmail. Replace USERNAME and PASSWORD with your Gmail account username and password respectively.
SmtpMailer::set_conf(array( 'default_from' => array( 'name' => 'your_name', 'email' => 'USERNAME@gmail.com' ), 'charset_encoding' => 'utf-8', 'server' => 'smtp.gmail.com', 'port' => 587, 'secure' => 'tls', 'authenticate' => true, 'user' => 'USERNAME@gmail.com', 'pass' => 'PASSWORD', 'debug' => 0, 'lang' => 'en' ));
Restart the servers for the changes to take effect:
$ sudo /opt/bitnami/ctlscript.sh restart
To configure the application to use other third-party SMTP services for outgoing email, such as SendGrid, refer to the FAQ.
NOTE: If you are using Gmail as the outbound email server, your application’s attempts to send outgoing emails may be blocked by Gmail if it considers the authentication attempts to be suspicious. When this happens, you will receive a Gmail security alert at the corresponding Gmail address. To proceed, you will need to manually confirm the validity of the authentication attempt before Gmail will permit the application to send outbound emails. For more information on this and other Gmail issues related to outbound email from your application, refer to our Gmail SMTP troubleshooting page.