PHP Classes

SMTP Mail

Recommend this page to a friend!

      MIME E-mail message sending  >  MIME E-mail message sending package blog  >  How Can PHP Send Emai...  >  All threads  >  SMTP Mail  >  (Un) Subscribe thread alerts  
Subject:SMTP Mail
Summary:header appears in e-mail when using SMTP.php...
Messages:6
Author:ron
Date:2008-06-16 21:38:06
Update:2008-06-18 08:35:58
 

  1. SMTP Mail   Reply   Report abuse  
Picture of ron ron - 2008-06-16 21:38:06
I'm not sure if this is a setting problem with my PHP code or a setting probelm with my ISP, but whenever I send e-mails via SMTP I get the following information in the header:

Content-Type: multipart/alternative;
boundary="=_127541a9c3f28cf5c8f8c6dff800bd18"
Message-ID: <k2jc0f.k0z12m@wiredpark.com>
To: rspark07@yahoo.com

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

My text message appears here

Then html message appears below it.

I can provide more details about which settings and php includes I actually use, but I was wondering if anyone knew the answer just based on this? It was working on another ISP, but now, I dont' know why I get all this extra info. Any ideas.

Ron



  2. Re: SMTP Mail   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-16 21:51:37 - In reply to message 1 from ron
Please provide a minimal example that can be used to reproduce the problem.

  3. Re: SMTP Mail   Reply   Report abuse  
Picture of ron ron - 2008-06-17 05:41:37 - In reply to message 2 from Manuel Lemos
HERE IS THE CODE:

<?php
require_once('htmlMimeMail.php');
require_once('smtp.php');

$from_address="xxx@wiredpark.com"; /* Change this to your address like "me@mydomain.com"; */
$from_name="Wired Park";

$url = "http://wiredpark.com/Activate.php?hash=".md5($_POST['pass'])."&stamp=".base64_encode($_POST['ts']);

$reply_name=$from_name;
$reply_address=$from_address;
$error_delivery_name=$from_name;
$error_delivery_address=$from_address;
$to_name=$_POST['user'];
$to_address=$_POST['email'];

$subject="Activate Your Wired Park User";
$text_message="Text Message";

$html_message="HTML Message";


$host_name="mail.wiredpark.com"; /* Change this variable to the address of the SMTP server to relay, like "smtp.myisp.com" */
$host_port=25; /* Change this variable to the port of the SMTP server to use, like 465 */
$localhost="http://wiredpark.com"; /* Your computer address */
$timeout=30; /* Set to the number of seconds wait for a successful connection to the SMTP server */
$smtpuser="user"; /* Set to the user name if the server requires authetication */
$smtppass="pass"; /* Set to the authetication password */

$mail = new htmlMimeMail();
$mail->setHtml($html_message, $text_message);
$mail->setReturnPath($from_address);

/*** Set some headers */
$mail->setFrom($from_address);
$mail->setSubject($subject);
$mail->setHeader('Activate your account', 'Wired Park');
$mail->setSMTPParams($host_name, $host_port, $localhost, 'TRUE', $smtpuser, $smtppass);


HERE IS THE E-mail Message via Yahoo Mail...This worked, when I used a local host and a different ISP for the SMTP server:

Activate your account: Wired Park
Content-Type: multipart/alternative;
boundary="=_127541a9c3f28cf5c8f8c6dff800bd18"
Message-ID: <k2jc0f.k0z12m@wiredpark.com>
To: rspark07@yahoo.com

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

Text Message

--=_127541a9c3f28cf5c8f8c6dff800bd18
Content-Type: text/html; charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

HTML Message
--=_127541a9c3f28cf5c8f8c6dff800bd18--

I great appreciate your help. It seems like it would be my ISP?

  4. Re: SMTP Mail   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-17 06:35:13 - In reply to message 3 from ron
That code is using a different e-mail message.

Use the MIME message class instead:

phpclasses.org/mimemessage

  5. Re: SMTP Mail   Reply   Report abuse  
Picture of ron ron - 2008-06-17 19:42:26 - In reply to message 4 from Manuel Lemos
OK,thanks for the help! I'll try that.

  6. Re: SMTP Mail   Reply   Report abuse  
Picture of ron ron - 2008-06-18 08:35:58 - In reply to message 5 from ron
Hi there. Me again. I changed the class again, and now am getting a message 'It was not previously established a SMTP connection'. I believe I have all the setting right for my ISP. Sorry to bother you again.

require("email_message.php");
require("smtp_message.php");
require_once('smtp.php');

$from_name='Wired Park';
$from_address="xxx@wiredpark.com"; $sender_line=__LINE__;
$reply_name=$from_name;
$reply_address=$from_address;
$reply_address=$from_address;
$error_delivery_name=$from_name;
$error_delivery_address=$from_address;

$to_name=$_POST['user'];
$to_address=$_POST['email']; $recipient_line=__LINE__;

$subject="header";
$message="text";

$email_message=new smtp_message_class;

/* This computer address */
$email_message->localhost="http://wiredpark.com";

/* SMTP server address, probably your ISP address,
$email_message->smtp_host="mail.wiredpark.com";

/* SMTP server port, usually 25 but can be 465 for Gmail */
$email_message->smtp_port=25;

/* Use SSL to connect to the SMTP server. Gmail requires SSL */
$email_message->smtp_ssl=0;

/* Deliver directly to the recipients destination SMTP server */
$email_message->smtp_direct_delivery=0;

/* In directly deliver mode, the DNS may return the IP of a sub-domain of
* the default domain for domains that do not exist. If that is your
* case, set this variable with that sub-domain address. */
$email_message->smtp_exclude_address="";

/* If you use the direct delivery mode and the GetMXRR is not functional,
* you need to use a replacement function. */
/*
$_NAMESERVERS=array();
include("rrcompat.php");
$email_message->smtp_getmxrr="_getmxrr";
*/

/* authentication user name */
$email_message->smtp_user="user";

/* authentication password */
$email_message->smtp_password="pass";

/* if you need POP3 authetntication before SMTP delivery,
* specify the host name here. The smtp_user and smtp_password above
* should set to the POP3 user and password*/
$email_message->smtp_pop3_auth_host="";

/* authentication realm or Windows domain when using NTLM authentication */
$email_message->smtp_realm="";

/* authentication workstation name when using NTLM authentication */
$email_message->smtp_workstation="";

/* force the use of a specific authentication mechanism */
$email_message->smtp_authentication_mechanism="";

/* Output dialog with SMTP server */
$email_message->smtp_debug=0;

/* if smtp_debug is 1,
* set this to 1 to make the debug output appear in HTML */
$email_message->smtp_html_debug=1;

/* If you use the SetBulkMail function to send messages to many users,
* change this value if your SMTP server does not accept sending
* so many messages within the same SMTP connection */
$email_message->maximum_bulk_deliveries=100;

$email_message->SetEncodedEmailHeader("To",$to_address,$to_name);
$email_message->SetEncodedEmailHeader("From",$from_address,$from_name);
$email_message->SetEncodedEmailHeader("Reply-To",$reply_address,$reply_name);
$email_message->SetHeader("Return-Path",$error_delivery_address);
$email_message->SetEncodedEmailHeader("Errors-To",$error_delivery_address,$error_delivery_name);
$email_message->SetEncodedHeader("Subject",$subject);
$email_message->AddQuotedPrintableTextPart($email_message->WrapText($message));
$error=$email_message->Send();
for($recipient=0,Reset($email_message->invalid_recipients);$recipient<count($email_message->invalid_recipients);Next($email_message->invalid_recipients),$recipient++)
echo "Invalid recipient: ",Key($email_message->invalid_recipients)," Error: ",$email_message->invalid_recipients[Key($email_message->invalid_recipients)],"\n";
if(strcmp($error,""))