Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

sending MIME HTML emails using SMTP


pstrid

Recommended Posts

Just switched hosting companies and now have to use SMTP to send emails (previously using sendmail without a problem)

 

Has anyone figure out how to get the send_order_html_email contribution working with SMTP (ie PEAR Mail::Factory)?

 

I have been able to make the changes to the includes/classes/email.php file so I can send emails using Mail:Factory but can only send in non-html format.

 

I am unable to figure out how to get MIME HTML emails to be sent that are generated using the send_order_html_email contribution.

 

Help please :(

Link to comment
Share on other sites

So, here's the code I using in my mail.php file.

if (EMAIL_TRANSPORT == 'smtp') {

			include_once("Mail.php");


			$user_contact = [email protected]';
			$headers["From"]	= $from;
			$headers["To"]	  = $to_addr;
			$headers["Subject"] = $subject;
			$headers["Bcc"] = "";
			$params["host"] = "scriptmail.xxx.net";
			$params["port"] = "25";
			$params["auth"] = false;
			$params["username"] = "";
			$params["password"] = "";

			// Create the mail object using the Mail::factory method
			$mail_object =& Mail::factory("smtp", $params);
			return $mail_object->send("$to_addr, [email protected]", $headers, $this->output);

 

A plain text email is delivered fine when I have Use MIME HTML When Sending Emails set to false. When set to true, the emails are still delivered but the HTML code comes through and is never rendered as HTML code. For Example, part of one of the emails would look like this:

--=_8f5de596bb60d92285923b8a86493f06
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

							  Store Name
		  ?							  Dear John Doe:							 ?							  Your order is: In Process*							 ?							  N?mero de Pedido:  Fecha del Pedido: Tuesday 03 January, 2006To view your order:http://www.storename.com/live/account_history_info.php?order_id=1043							 Other Comments:

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; charset= =3Diso-8859-1"> <base href=3D"http://www.storename.com/live/"> <lin= k rel=3D"stylesheet" type=3D"text/css" href=3D"stylesheetmail.css"> </head>= <body><div align=3D"center"> <table width=3D"600" border=3D"0" cellpadding=
=3D"2" cellspacing=3D"0" > <tr> 	 <td><table border=3D"0" width=3D"100%" ce=
llspacing=3D"0" cellpadding=3D"2" > 		  <tr>		   <td class=3D"page=
Heading" valign=3D"bottom" align=3D"center">

 

Thinking i may have to add some include like

include('Mail/mime.php');

Help is needed greatly:( Thanks!

Link to comment
Share on other sites

Hi,

 

Just wanted to say that I've got the same trouble with source code format but I'm not using the SMTP. I use SendMail and I still have exactly the same symptoms. The graphical result is correct but the source is just not.

 

I'll keep looking and let you know if I find anything.

 

Xiao

Link to comment
Share on other sites

  • 7 months later...
  • 8 months later...

DID this ever get solved? I am trying to use the Pear html contrib, but as stated in the contrib, the mime/html is not working. That is true.

I was able to send mime emails using sendmail, but I have switched to using Pear for email so I can use SMTP, but the html comes through all garbled. I have also tried using the Pear Mail_mime, but that is not working (or I am not doing something right).

Link to comment
Share on other sites

  • 6 years later...

I was faced with this exact problem when enabling the HTML MIME option via the admin control panel also (osc 2.3.3).

 

I was able to fix it by modifying the tep_mail() function in general.php .. here is my version, it works:

 

 function tep_mail($to_name, $to_email_address, $email_subject, $email_text, $from_email_name, $from_email_address) {
   if (SEND_EMAILS != 'true') return false;
   // Instantiate a new mail object
   $message = new email(array('X-Mailer: osCommerce'));
   // Build the text version
   $text = strip_tags($email_text);
   if (EMAIL_USE_HTML == 'true') {
  $message->add_html($email_text, $text);
   } else {
  $message->add_text($text);
   }
   // Send message
   $message->build_message();

   $to = $to_email_address;
   $subject = $email_subject;
   $headers = "From: " . $from_email_address . "\r\n";
   $headers .= "Reply-To: ". $from_email_address . "\r\n";
   $headers .= "MIME-Version: 1.0\r\n";
   $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";

   mail($to_email_address,$email_subject,$email_text,$headers);
 }

 

Basically something funky with the $message->send line, now instead I am just using the regular mail() function.

 

Regards,

Jason

Link to comment
Share on other sites

  • 3 years later...
  • 1 year later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...