virtualMachinesilverstripe

Configure SMTP for outbound emails

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 or Mandrill, refer to the FAQ.

NOTE: If you are using Gmail as the outbound email server and have experienced issues trying to send emails correctly, check the Gmail SMTP troubleshooting page to learn the causes of these issues and how to solve them.