How to setup osCommerce to use SMTP

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. The URL should be similar to http://yourdomain.com/admin.
  2. Go to Configuration > Email Options.
  3. 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

Under the General Store configuration you have to check that the Email Address and Email From fields are set with the ones that you want to use for sending the messages.

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 a copy of phpMailer: http://addons.oscommerce.com/info/5233

2. Connect with FTP or File Manager to your osCommerce installation folder and copy the filesclass.phpmailer.php and class.smtp.php into these folders:

/home/cPanel-username/public_html/osCommerce_installation_folder/admin/includes/classes

/home/cPanel-username/public_html/osCommerce_installation_folder/includes/classes/

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

/home/cPanel-username/public_html/osCommerce_installation_folder/includes/classes/email.php

/home/cPanel-username/public_html/osCommerce_installation_folder/admin/includes/classes/email.php

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

[sourcecode language="php"]
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$
}
}
[/sourcecode]

Please comment the following lines as described:

[sourcecode language="php"]
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$
//      }
//    }
[/sourcecode]

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!

[sourcecode language="php"]
require_once(DIR_WS_CLASSES . "class.phpmailer.php");
$pMail = new PHPMailer();
$pMail->From     = $from_addr;
$pMail->FromName = $from_name;
$pMail->IsSMTP();
$pMail->Host     = "mail.yourdomain.com";       // replace with your SMTP server
$pMail->Username = "account@yourdomain.com";      // 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);
$pMail->IsHTML(false);
return $pMail->Send();
$pMail->ClearAddresses();
$pMail->ClearAttachments();
}
}
[/sourcecode]

The aforementioned 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.

You need help with a shopping cart? hostlantern is specialized in eCommerce hosting and provides expert support for a large number of shopping carts. Check out our shopping cart hosting services!

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

How To Secure OsCommerce

In order to secure OsCommerce please follow these steps: 1. Download all your OsCommerce files...

OsCommerce Security Check

If you have any doubts that your OsCommerce security has been compromised please follow these...

OsCommerce Admin Login Problems

If you cannot log into your OsCommerce admin area try the following: 1. Open your OsCommerce...

How to optimize osCommerce for better performance?

osCommerce is one of the most popular free shopping cart applications currently available. Here...

How to configure osCommerce to work with a new domain?

In order to configure osCommerce to work properly with another domain, you should modify the...

Powered by WHMCompleteSolution