PHP Classes

send to smtp server

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  >  send to smtp server  >  (Un) Subscribe thread alerts  
Subject:send to smtp server
Summary:problem when send to smtp server
Messages:2
Author:Anatoli Marinov
Date:2008-06-26 11:26:32
Update:2008-06-29 00:38:55
 

  1. send to smtp server   Reply   Report abuse  
Picture of Anatoli Marinov Anatoli Marinov - 2008-06-26 11:26:32
Resolving SMTP server domain "mail.ti-wmc.nik*****"...
Connecting to host address "83.172.151.182" port 25...
Connected to SMTP server "mail.ti-wmc.nik*****".
S 220 ns1.nik***** ESMTP
C EHLO tcl.nik*****
S 250-ns1.nik*****
S 250-AUTH=LOGIN CRAM-MD5 PLAIN
S 250-AUTH LOGIN CRAM-MD5 PLAIN
S 250-STARTTLS
S 250-PIPELINING
S 250 8BITMIME
Error: it was not previously established a SMTP connection

I got this error. What could be the problem. There is not good error message.

my php code is :
$from_name=$options["from_name"];
$from_address=$options["from_address"]; $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=$options["to_name"];
$to_address=$options["to_address"]; $recipient_line=__LINE__;
$subject=$options["subject"];
$message=$options["text_message"];

$email_message=new smtp_message_class;

/* This computer address */
$email_message->localhost="tcl.nik*****";

/* SMTP server address, probably your ISP address,
* or smtp.gmail.com for Gmail */
$email_message->smtp_host="mail.ti-wmc.nik*****";

/* 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="";

/* authentication user name */
$email_message->smtp_user="info@ti-wmc.nik*****";

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

/* 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=1;

/* 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));

if($options["attached_file"] != "") {
$attachment=array(
"FileName"=>$options["attached_file"],
"Content-Type"=>"automatic/name",
"Disposition"=>"attachment"
);
$email_message->AddFilePart($attachment);
}

$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,""))
echo "Error: $error\n";
else
echo "Done.\n";


Thanks in advance

  2. Re: send to smtp server   Reply   Report abuse  
Picture of Manuel Lemos Manuel Lemos - 2008-06-29 00:38:55 - In reply to message 1 from Anatoli Marinov
That error is caused when for some reason the SMTP class is requested to disconnect from the server when it is already disconnected. So there may a bug making that happen.

Anyway, I think your real problem is that you are trying to use a SMTP server that requires authentication but you do not seem to be including the SASL class. In that case, make sure you include sasl.php in the beginning of your script.