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 tohttp://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 files class.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.

Posted in: OsCommerce

Related FAQ's

Marius Ion ANGEL HOT SOFT LLC (800) 316-7677