How to send email from Opencart

Programming, error messages and sample code > PHP
There should be 3 steps to set up the email service for your Opencart website.
1, Please login to your Opencart website admin page to set up the SMTP settings.

    Login to your site backend-->system-->settings-->mail
    Mail Protocol: We only support SMTP protocol, so please choose SMTP.
    Mail Paramaters: Just ignore this, because this is only used for Mail protocol.  
    SMTP Host: The address of the smtp host.
    SMTP Username: The full email address.
    SMTP Password
: Your email account password
    SMTP Port: 25
    SMTP Timeout: use the default parameter.
    New Order Alter Mail: Select 'Yes' will send a notification email for every order submitted in the store front.
    New Account Alert Mail: Select 'Yes' will send a notification email for every account created in the store front.
    Additional Alert E-mails: List any additional e-mails that should also receive the notification emails above.



 
2, Please login to your site backend-->system-->General to set the correct store owner's email address.



 

3. Locate to file \system\library\mail.phpline 274 and line 276 from file manager or ftp,

replace

$this->from

with

$this->username

 

Please note : If you are using Opencart (v2.1.0.1) that installed from Control Panel > APP Installer, you may need to replace lines 312 and 314 with below:

if ($this->verp) {
    fputs($handle, 'MAIL FROM: <' . $this->smtp_username . '>XVERP' . "\r\n");
} else {
    fputs($handle, 'MAIL FROM: <' . $this->smtp_username . '>' . "\r\n");
}
 

If you are using Opencart with higher version, just make sure you select "SMTP" Mail Protocol.