Jorge Batres
asked on
PHP Deprecated: The each() function is deprecated
Hi, I have a deprecated each() function on line 89 of this script. Could you please help me with a replacement for this deprecated function?
Thanks,
Jorge Batres
<?php
/*
* test_smtp_message.php
*
* @(#) $Header: /home/mlemos/cvsroot/PHPlibrary/test_smtp_message.php,v 1.4 2002/08/12 04:46:15 mlemos Exp $
*
*/
require("mimemessage/email_message.php");
require("mimemessage/smtp_message.php");
require("mimemessage/smtp.php");
function mime_mail($server, $from_name, $from_address, $pass, $to_address, $subject, $message, $html_message = "", $attachments = array(), $other_headers = "") {
/*
$attachment=array(
"Data"=> "This is just a plain text attachment file named attachment.txt .",
"Name"=>"attachment.txt",
"Content-Type"=>"automatic/name",
"Disposition"=>"attachment"
);
*/
$debug = date("H:i:s");
$error1 = "";
$reply_name=$from_name;
$reply_address=$from_address;
$error_delivery_name=$from_name;
$error_delivery_address=$from_address;
$to_name="";
$email_message=new smtp_message_class;
if($server=="gmail") {
$email_message->protocol = "tls://";
$email_message->smtp_port=465; /* SMTP server address */
$email_message->smtp_host="smtp.gmail.com"; /* SMTP server address */
$email_message->smtp_user=$from_address; /* authentication user name */
$email_message->smtp_password=$pass; /* authentication password */
}
else {
global $use_local_smtp;
$use_local_smtp = true;
$email_message->smtp_host="localhost"; /* SMTP server address */
$email_message->smtp_port=25; /* SMTP server address */
}
//$email_message->smtp_port=465; /* SMTP server address */
//$email_message->smtp_port=465; /* SMTP server address */
$email_message->smtp_direct_delivery=0; /* Deliver directly to the recipients destination SMTP server */
$email_message->smtp_exclude_address=""; /* 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. */
/*
* 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";
*/
$email_message->smtp_realm=""; /* authentication realm */
$email_message->smtp_debug=0; /* Output dialog with SMTP server */
$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->SetHeader("Content-Type", "multipart/mixed");
$email_message->SetOtherHeaders($other_headers); //Trevor
if ($html_message) {
$html_part = 0;
$text_part = 0;
$email_message->CreateQuotedPrintableHTMLPart($html_message,"",$html_part);
//$email_message->CreateRelatedMultipart($related_parts,$html_parts);
$email_message->CreateQuotedPrintableTextPart($email_message->WrapText($message),"",$text_part);
$alternative_parts=array(
$text_part,
$html_part
); //was $html_parts
$email_message->AddAlternativeMultipart($alternative_parts);
} else {
$email_message->AddQuotedPrintableTextPart($email_message->WrapText($message));
}
if (is_array($attachments)) {
for (reset($attachments); list(, $attachment) = each($attachments); ) {
$email_message->AddFilePart($attachment);
}
}
$debug .= " - " . (string) date("H:i:s");
$error=$email_message->Send();
$debug .= " - " . (string) date("H:i:s");
for($recipient=0,Reset($email_message->invalid_recipients);$recipient<count($email_message->invalid_recipients);Next($email_message->invalid_recipients),$recipient++)
$error1 = "Invalid recipient: \n" . Key($email_message->invalid_recipients) . "\n Error: " . $email_message->invalid_recipients[Key($email_message->invalid_recipients)] . "\n";
if(strcmp($error,""))
$error1 = "Error: $error\n";
$error1 and die($error1);
return $debug;
return (!$error1);
}
?>
Thanks,
Jorge Batres
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
No worries :)
ASKER
Jorge Batres