InMotion Hosting Support Center

OsCommerce supports the use of SMTP to send email, but does not allow specification of a username and password for outgoing authentication, which is required when sending mail from our servers.

If you are on a server that does not allow the PHP mail() function or you just wish to use SMTP to send mail, this guide will walk you through how to set up SMTP with your shopping cart.

It is best to use an email address that you created in your cPanel on our server for the SMTP setup, but you can use your outgoing email settings for most other mail providers to send emails.

First thing to do is log in to the administrative panel, then go to Configuration ~> Email options and choose "SMTP" as the Transport Method.

Also verify these other settings:

Email Line Feels: LF
Use MIME EMail when sending email: YES
Verify E-Mail Addresses Through DNS : FALSE
Use MIME HTML When Sending Emails: FALSE

Also check the the General Store configuration to see that the Email Address and Email From fields are the same as the outgoing email address you'll be using for the setup.

You'll need to install a 3rd party script called phpMailer. As with any other time, please make a backup copy of any files you are changing in case something goes wrong!

To install phpMailer:

1. Download a copy of phpMailer

2. There are two files, class.phpmailer.php and class.smtp.php. Open the FTP site to the OScommerce installation, then upload them both into these folders:


3. There are two files in OsCommerce that you need to edit:


In the email.php file, locate this section: (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$

You'll need to comment out some of these lines, so they look like this:

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$
// }
// }

Then copy and paste this code directly below those lines. Be sure to change the Host, Username, and Password fields to match the outgoing mail server.  When sending from our systems, please just use 'localhost' as the host, and your entire email address as the username.

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 = ""; // replace with your smtp username (if SMTPAuth is true)
$pMail->Password = "password"; // replace with your smtp password (if SMTPAuth is true)
$pMail->SMTPAuth = true; // true/false - turn on/off smtp authentication
$pMail->Subject = $subject;
$pMail->Body = $this->output;
$pMail->AddAddress($to_addr, $to_name);
return $pMail->Send();

This needs to be done for both email.php files in order to get the user-side and backend emailing to work. There is a sample email.php available here:

Was this article helpful?
Continued Education in Course 105: Testing the osCommerce site
You are viewing Section 1: Setting up SMTP with osCommerce
Section 2: Sending out email in osCommerce Video

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question

Support Center Login

Our Login page has moved. Please click the button below to be redirected to the login page.

n/a Points
2016-07-09 2:22 am

Hey thanks for the prompt reply, but I am currently working on it locally. I have tried setting permissions and everything. But nothing seems to work. So there may be no way you could test it.



43,761 Points
2016-07-11 1:16 pm
Have you set your local environment to be able to function as a mail server? This is often a problem with testing locally vs on a hosting server.
n/a Points
2016-07-08 7:08 am

Hi guys,

I have tried to do this but I am getting an error at the registration of a customer. The error is Fatal error: Call to undefined method stdClass::IsSMTP()

      require_once(DIR_WS_CLASSES . "class.phpmailer.php");

      $pmail = new PHPMailer();

Can anybody help me with this?

I would be really grateful.

Thanks and Regards,


31,499 Points
2016-07-08 9:02 am
We are happy to help, but will need some additional information. Can you provide a link to the form for us to test?

Thank you,
13,821 Points
2016-01-29 8:54 am
This would be hard to diagnose without seeing what you've changed. Sorry, wish we could be more help.
n/a Points
2016-02-01 7:53 am

I added a BCC to the mail logic and it works now alltough admin gets the same mail twice now...

n/a Points
2016-01-28 8:36 am


I applied the SMTP tweak. Works fine!

Except one thing: the admin normally got an copy of any order confirmation but not anymore.

I edited only the email.php class file and uploaded the main smtp class files from the "package".


any idea?

Thank you.

n/a Points
2015-05-26 1:43 am

Hi There,

I configured smtp with phpmailer and also it works but in some case(not regularaly) it giving following error.


SMTP Error: Could not authenticate.

Please help me.



10,077 Points
2015-05-27 12:51 am
Hello Ranjit,

I found a forum thread from OS Commerce's website of someone who had a fairly similar issue. Please check it out as it should be able to help your situation.

Best Regards,
TJ Edens
n/a Points
2015-05-20 10:35 am

YES, PLEASE FIX YOUR POST! I only saw the comment correction above after installing & getting a errror due to the extraneous right angle bracket!!

42,678 Points
2015-05-21 10:49 am
Hello Zdub,

It's been fixed! If you have any further questions or comments, please let us know.

Arnel C.
n/a Points
2014-07-28 10:51 am

In the second line of the Paste in code there is a mistake.

$pMail = new PHPMailer(); >$pMail->From = $from_addr;

should be changed to

$pMail = new PHPMailer();

$pMail->From = $from_addr; 

Post a Comment

Email Address:
Phone Number:

Please note: Your name and comment will be displayed, but we will not show your email address.

12 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail:
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!