How to setup SMTP authentication in OSCommerce site to send emails

Auto-Install Applications > OSCommerce


Before we proceed, the phpMailer script must be installed so that we could set the SMTP functionality properly.

( Please backup your files before proceeding with the following steps)

To install phpMailer:

1. Download phpMailer:

2. Find files class.phpmailer.php and class.smtp.php from phpMailer package.


Then upload them into these folders:


click here to see how to upload files from your control panel

3. Access the following files and edit them according to the examples provided below:



Inside each of the email.php files you have to locate the following section around line 519:

if (EMAIL_TRANSPORT == ‘smtp’) {
return mail($to_addr, $subject, $this->output, ‘From: ‘ . $from . $this->lf . ‘To: ‘ . $to .   $this->lf . implode($this->lf, $$
} else {
return mail($to, $subject, $this->output, ‘From: ‘.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this$
Please comment the following lines:


if (EMAIL_TRANSPORT == ‘smtp’) {
//return mail($to_addr, $subject, $this->output, ‘From: ‘ . $from . $this->lf . ‘To: ‘ . $to . $this->lf . implode($this->lf, $$
//} else {
//return mail($to, $subject, $this->output, ‘From: ‘.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this$
Next, copy and paste the following code directly below the last commented line. The Host, Username and Password fields should be set according to your outgoing mail server. Note that the Username fieled should contain the full email address!
if (EMAIL_TRANSPORT == ‘smtp’) {
//return mail($to_addr, $subject, $this->output, ‘From: ‘ . $from . $this->lf . ‘To: ‘ . $to . $this->lf . implode($this->lf, $$
//} else {
//return mail($to, $subject, $this->output, ‘From: ‘.$from.$this->lf.implode($this->lf, $this->headers).$this->lf.implode($this$
require_once(DIR_WS_CLASSES . "class.phpmailer.php");
$pMail = new PHPMailer();
$pMail->From     = $from_addr;
$pMail->FromName = $from_name;
$pMail->Host     = "";       // replace with your SMTP server
$pMail->Username = "[email protected]";      // replace with your SMTP username
$pMail->Password = "password";          // replace with your SMTP password
$pMail->SMTPAuth = true;                        // SMTP authentication must be always turned on (true)
$pMail->Subject = $subject;
$pMail->Body    = $this->output;
$pMail->AddAddress($to_addr, $to_name);
return $pMail->Send();
The changes should be appyed to both of the email.php files so that both the front-end and back-end of your application could successfully sent emails.

Configure your OSCommerce

OSCommerce could be setup to use the SMTP functionality inside its back-end, but there are some manual modifications needed in order to fully setup the SMTP functionality of this application. Follow these steps to complete the setup:

    1 Access the OSCommerce Administrative Panel.
    2 Go to Configuration > My Store to see if the Email Address and Email From fields are the same as the outgoing email address you'll be using for the setup.
    3 Go to Configuration > Email Options
    4 Choose “SMTP” as the Transport Method.

Also verify these other settings:

Email Line Feels: LF

Verify E-Mail Addresses Through DNS: false

Use MIME HTML When Sending Emails: false

Send E-Mails: true



Register an account first ,then Go to Administrative Panel > Tools > Send Email to have a try