if (!$massmail || $massmail && $hcc == 0) { //create text/html part: send_log("Newsletter is from type: '" . $NL[0]['content_type'] . "'"); //we want mixed multipart, with alternative text/html and attachements, inlineimages and all that //text part must be the first one!!! if ($NL[0]['content_type'] == "text" || $NL[0]['content_type'] == "text/html") { $use_textpart = true; send_log("create TEXT Part"); //only create part $email_obj->CreateQuotedPrintableTextPart($email_obj->WrapText($NLBODY_TEXT), "", $mimepart_text); } if ($NL[0]['content_type'] == "html" || $NL[0]['content_type'] == "text/html") { $use_htmlpart = true; send_log("create HTML Part"); //only create part $email_obj->CreateQuotedPrintableHtmlPart($NLBODY, "", $mimepart_html); } $partids = array(); //array of partnumbers, returned by reference from createpart etc if ($use_textpart) { array_push($partids, $mimepart_text); if (DEBUG) { send_log(print_r($mimepart_text)); } } if ($use_htmlpart) { array_push($partids, $mimepart_html); if (DEBUG) { send_log(print_r($mimepart_html)); } }
function SendMail_smtp($from_address, $from_name, $to_address, $to_name, $subject, $text, $html, $AttmFiles = array(), $HOST = array()) { global $encoding, $tm_URL_FE; //use default encoding $return = false; if (!isset($HOST[0])) { $HOSTS = new tm_HOST(); $HOST = $HOSTS->getStdSMTPHost(); } //using http://www.phpclasses.org/trackback/browse/package/9.html http://www.phpclasses.org/browse/package/14.html http://www.phpclasses.org/trackback/browse/package/14.html //Class: MIME E-mail message composing and sending //thx to Manuel Lemos <mlemos at acm dot org> //look at: http://freshmeat.net/projects/mimemessageclass/ require_once "Class_SMTP.inc.php"; $email_message = new smtp_message_class(); $email_message->default_charset = $encoding; $email_message->authentication_mechanism = $HOST[0]['smtp_auth']; /* This computer address */ $email_message->localhost = $HOST[0]['smtp_domain']; $email_message->ssl = $HOST[0]['smtp_ssl']; /* SMTP server address, probably your ISP address */ $email_message->smtp_host = $HOST[0]['host']; $email_message->smtp_port = $HOST[0]['port']; /* authentication user name */ $email_message->smtp_user = $HOST[0]['user']; /* authentication realm or Windows domain when using NTLM authentication */ $email_message->smtp_realm = ""; /* authentication workstation name when using NTLM authentication */ $email_message->smtp_workstation = ""; /* authentication password */ $email_message->smtp_password = $HOST[0]['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 = ""; /* Output dialog with SMTP server */ $email_message->smtp_html_debug = 0; /* if smtp_debug is 1, * set this to 1 to make the debug output appear in HTML */ if (DEBUG_SMTP) { $email_message->smtp_debug = 1; } else { $email_message->smtp_debug = 0; $email_message->smtp_html_debug = 0; } $email_message->maximum_piped_recipients = $HOST[0]['smtp_max_piped_rcpt']; //sends only XX rcpt to before waiting for ok from server! $email_message->mailer = TM_APPTEXT . " using smtp"; $email_message->SetEncodedEmailHeader("To", $to_address, $to_name); $email_message->SetEncodedEmailHeader("From", $HOST[0]['sender_email'], $HOST[0]['sender_name']); $email_message->SetEncodedEmailHeader("Reply-To", $HOST[0]['reply_to'], $HOST[0]['sender_name']); $email_message->SetHeader("Return-Path", $HOST[0]['return_mail']); $email_message->SetEncodedEmailHeader("Errors-To", $HOST[0]['return_mail'], $HOST[0]['sender_name']); $email_message->SetEncodedHeader("List-Unsubscribe", $tm_URL_FE . "/unsubscribe.php"); $email_message->SetEncodedHeader("Subject", $subject); $partids = array(); //array of partnumbers, returned by reference from createpart etc //we want mixed multipart, with alternative text/html and attachements, inlineimages and all that //text part must be the first one!!! //only add part $email_message->CreateQuotedPrintableTextPart($text, "", $partids[]); $email_message->CreateQuotedPrintableHtmlPart($html, "", $partids[]); //AddAlternativeMultiparts $email_message->AddAlternativeMultipart($partids); //attachements //filenames stored in Array $AttmFiles if ($AttmFiles) { foreach ($AttmFiles as $AttmFile) { $attachment = array("FileName" => $AbsPath . "/" . $AttmFile, "Content-Type" => "automatic/name", "Disposition" => "attachment"); $email_message->AddFilePart($attachment); } //for each } //ifAttmFiles $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, "")) { $return[0] = false; $return[1] = $error; } if (empty($error)) { $return[0] = true; $return[1] = ""; } return $return; }