/** * Sendas retmesagxon al iu h**o. * * $subjekto - temlinio de la mesagxo (en UTF-8, EO-signoj per c^-kodigo) * $korpo - la teksto de la mesagxo (dito) * $to_name - la nomo de la ricevonto (dito) * $to_adress - la retposxtadreso de la ricevonto */ function sendu_xxxxx_mesagxon($subjekto, $korpo, $to_name, $to_address) { $subject = eotransformado($subjekto, "utf-8"); // $mesagxo = "### auxtomata mesagxo de la DEJ-aligilo ###\n\n"; $mesagxo .= eotransformado($korpo, "utf-8"); $from_name = "Pauxlo Ebermann"; // TODO: (eble prenu nomon aux el la datumbazo/konfiguro, aux la entajpanton ?) $from_address = "*****@*****.**"; // TODO: Eble prenu el la datumbazo? $email_message = new email_message_class(); $email_message->default_charset = "UTF-8"; if (!strcmp($error = $email_message->SetEncodedEmailHeader("To", $to_address, eotransformado($to_name, "utf-8")), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("From", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("Reply-To", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedHeader("Errors-To", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("Bcc", "*****@*****.**", "Paul Ebermann"), "") && !strcmp($error = $email_message->SetEncodedHeader("Subject", $subject), "") && !strcmp($error = $email_message->AddQuotedPrintableTextPart($email_message->WrapText($mesagxo)), "")) { $error = $email_message->Send(); } if ($error) { erareldono($error); exit; } }
/** * aldonas dosieron kreita enmemore. * * @param string $enhavo la enhavo de la dosiero (kiel bitoka cxeno). * @param string $nomo la dosiernomo por nomi la aldonajxon. * @param string $tipo la enhavtipo. Se ne donita, ni provos diveni gxin * laux la nomo de la dosiero. */ function aldonu_dosieron_el_memoro($enhavo, $nomo, $tipo = "") { $datoj = array('Data' => $enhavo, 'Name' => $nomo, 'Content-Type' => $tipo ? $tipo : 'automatic/name'); $eraro = $this->baza_objekto->AddFilePart($datoj); $this->testu_eraron($eraro); }
* $from_name="My Name"; */ $from_address = getenv("USER") . "@" . getenv("HOSTNAME"); $from_name = getenv("USERNAME"); $reply_name = $from_name; $reply_address = $from_address; $reply_address = $from_address; $error_delivery_name = $from_name; $error_delivery_address = $from_address; /* * Change these lines or else you will be mailing the class author. */ $to_name = "Manuel Lemos"; $to_address = "*****@*****.**"; $subject = "Testing Manuel Lemos' MIME E-mail composing and sending PHP class: HTML message"; $email_message = new email_message_class(); $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("Sender", $from_address); /* * Set the Return-Path header to define the envelope sender address to which bounced messages are delivered. * If you are using Windows, you need to use the smtp_message_class to set the return-path address. */ if (defined("PHP_OS") && strcmp(substr(PHP_OS, 0, 3), "WIN")) { $email_message->SetHeader("Return-Path", $error_delivery_address); } $email_message->SetEncodedHeader("Subject", $subject); /* * An HTML message that requires any dependent files to be sent, * like image files, style sheet files, HTML frame files, etc..,
*/ $from_address = getenv("USER") . "@" . getenv("HOSTNAME"); $from_name = getenv("USERNAME"); $reply_name = $from_name; $reply_address = $from_address; $reply_address = $from_address; $error_delivery_name = $from_name; $error_delivery_address = $from_address; /* * Change these lines or else you will be mailing the class author. */ $to_name = "Manuel Lemos"; $to_address = "*****@*****.**"; $to_address = "*****@*****.**"; $subject = "Testing Manuel Lemos' MIME E-mail composing and sending PHP class: HTML message"; $email_message = new email_message_class(); $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("Sender", $from_address); /* * Set the Return-Path header to define the envelope sender address to which bounced messages are delivered. * If you are using Windows, you need to use the smtp_message_class to set the return-path address. */ if (defined("PHP_OS") && strcmp(substr(PHP_OS, 0, 3), "WIN")) { $email_message->SetHeader("Return-Path", $error_delivery_address); } $email_message->SetEncodedHeader("Subject", $subject); $html_message = "<html>\n<head>\n<title>{$subject}</title>\n<style type=\"text/css\"><!--\nbody { color: black ; font-family: arial, helvetica, sans-serif ; background-color: #A3C5CC }\nA:link, A:visited, A:active { text-decoration: underline }\n--></style>\n</head>\n<body>\n<table width=\"100%\">\n<tr>\n<td>\n<center><h1>{$subject}</h1></center>\n<hr>\n<P>Hello " . strtok($to_name, " ") . ",<br><br>\nThis message is just to let you know that the <a href=\"http://www.phpclasses.org/mimemessage\">MIME E-mail message composing and sending PHP class</a> is working as expected.<br><br>\nThank you,<br>\n{$from_name}</p>\n</td>\n</tr>\n</table>\n</body>\n</html>"; $email_message->CreateQuotedPrintableHTMLPart($html_message, "", $html_part); /*
* $from_name="My Name"; */ $from_address = getenv("USER") . "@" . getenv("HOSTNAME"); $from_name = getenv("USERNAME"); $reply_name = $from_name; $reply_address = $from_address; $reply_address = $from_address; $error_delivery_name = $from_name; $error_delivery_address = $from_address; /* * Change these lines or else you will be mailing the class author. */ $to_name = "Manuel Lemos"; $to_address = "*****@*****.**"; $subject = "[Fwd: Testing Manuel Lemos' MIME E-mail composing and sending PHP class for sending messages that include forwarded messages]"; $email_message = new email_message_class(); $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); /* * Set the Return-Path header to define the envelope sender address to * which bounced messages are delivered. * If you are using Windows, you need to use the smtp_message_class to set * the return-path address. */ if (defined("PHP_OS") && strcmp(substr(PHP_OS, 0, 3), "WIN")) { $email_message->SetHeader("Return-Path", $error_delivery_address); } $email_message->SetEncodedHeader("Subject", $subject); /* * A message with attached files usually has a text message part
function send($to = '') { $this->error = ''; /* * check if newsletter and issue are set */ if (!is_object($this->c_newsletter) || !is_object($this->c_issue)) { $this->error = 'No valid newsletter issue set'; $this->log->error($this->error); return false; } /* * check if text or html messages are set */ $message = $this->composeText(); $html = $this->composeHtml(); if (empty($message) && empty($html)) { $this->error = 'No content set'; $this->log->error($this->error); return false; } /* * now prepare email */ $from_name = $this->c_newsletter->sender_name; $from_address = $this->c_newsletter->getSender(); if (empty($from_address)) { $this->error = 'No valid sender address set'; $this->log->error($this->error); return false; } $reply_name = $from_name; $reply_address = $this->c_newsletter->getReply(); if (empty($reply_address)) { $reply_address = $from_address; } $error_delivery_name = $from_name; $error_delivery_address = $this->c_newsletter->getReturn(); if (empty($error_delivery_address)) { if (empty($GLOBALS['tnl_error_email'])) { $error_delivery_address = $from_address; } else { $error_delivery_address = $GLOBALS['tnl_error_email']; } } if (empty($to)) { $to = $this->c_newsletter->getSubscribers(); } elseif (!is_array($to)) { $to = array($to); } /*array( array( 'UID' => '0000001', "address"=>"*****@*****.**", "name"=>"Peter Gabriel" ), array( 'UID' => '0000002', "address"=>"*****@*****.**", "name"=>"Paul Simon" ), array( 'UID' => '0000003', "address"=>"*****@*****.**", "name"=>"Mary Chain" ) );*/ $subject = $this->c_issue->title; switch (XOX_MAILER_TYPE) { case 'pickup': $email_message = new pickup_message_class(); $email_message->dir_sep = '/'; $email_message->mailroot_directory = XOX_APP_BASE . '/jobs'; $email_message->pickup_file_prefix = date('YmdHis') . '_'; $email_message->pickup_file_postfix = '.eml'; break; case 'sendmail': $email_message = new sendmail_message_class(); $email_message->delivery_mode = SENDMAIL_DELIVERY_DEFAULT; /* Mode of delivery of the message. Supported modes are: * SENDMAIL_DELIVERY_DEFAULT - Default mode * SENDMAIL_DELIVERY_INTERACTIVE - Deliver synchronously waiting for remote server response. * SENDMAIL_DELIVERY_BACKGROUND - Deliver asynchronously without waiting for delivery success response. * SENDMAIL_DELIVERY_QUEUE - Leave message on the queue to be delivered later when the queue is run * SENDMAIL_DELIVERY_DEFERRED - Queue without even performing database lookup maps. */ $email_message->bulk_mail_delivery_mode = SENDMAIL_DELIVERY_QUEUE; /* Mode of delivery of the message when the class is set to the bulk mail delivery mode */ $email_message->sendmail_arguments = ""; /* Additional sendmail command line arguments */ break; case 'qmail': case 'smtp': case 'mail': default: $email_message = new email_message_class(); break; } echo "<table style='font-size:11px'><tr><td><b>From</b></td><td>{$from_address}, {$from_name}</td></tr>"; echo "<tr><td><b>Reply-To</b></td><td>{$reply_address}, {$reply_name}</td></tr>"; echo "<tr><td><b>Errors-To</b></td><td>{$error_delivery_address}, {$error_delivery_name}</td></tr>"; if (count($to) < 100) { foreach ($to as $subscriber) { echo '<tr><td><b>To</b></td><td>' . $subscriber->email . '</td></tr>'; } } else { echo '<tr><td></td><td><b>Massenmailing</b></td></tr>'; } echo '</table>'; /* * For faster queueing use qmail... * * require_once("qmail_message.php"); * $email_message=new qmail_message_class; * * or sendmail in queue only delivery mode * * require_once("sendmail_message.php"); * $email_message=sendmail_message_class; * $email_message->delivery_mode=SENDMAIL_DELIVERY_QUEUE; * * Always call the SetBulkMail function to hint the class to optimize * its behaviour to make deliveries to many users more efficient. */ $email_message->SetBulkMail(1); $email_message->SetEncodedEmailHeader("From", $from_address, $from_name); $email_message->SetEncodedEmailHeader("Reply-To", $reply_address, $reply_name); /* * Set the Return-Path header to define the envelope sender address * to which bounced messages are delivered. * If you are using Windows, you need to use the smtp_message_class * to set the return-path address. */ if (!XOX_LOCAL_MODE) { $email_message->SetHeader("Return-Path", $error_delivery_address); } $email_message->SetEncodedEmailHeader("Errors-To", $error_delivery_address, $error_delivery_name); $email_message->SetEncodedHeader("Subject", $subject); // make sure text is not cached for personalization $email_message->cache_body = 0; // create copy for text only $email_text = $email_message; /* Create empty parts for the parts that will be personalized for each recipient. */ $email_message->CreateQuotedPrintableTextPart($message, "", $text_part); $email_message->CreateQuotedPrintableHTMLPart($html, "", $html_part); $email_text->CreateQuotedPrintableTextPart($message, "", $text_only_part); /* * Multiple alternative parts are gathered in multipart/alternative parts. * It is important that the fanciest part, in this case the HTML part, * is specified as the last part because that is the way that HTML capable * mail programs will show that part and not the text version part. */ $alternative_parts = array($text_part, $html_part); $email_message->AddAlternativeMultipart($alternative_parts); /* Add the empty part wherever it belongs in the message. */ $email_text->AddPart($text_only_part); /* Iterate personalization for each recipient. */ $count_to = count($to); if (MAILTEST_ACTIVE && $count_to > MAILTEST_MAX_MAILS) { $count_to = MAILTEST_MAX_MAILS; } $tmp = new xoxSimpleTemplate('', '', '', '\\{\\$', '\\}'); $tmp->setVar('DOMAINID', $this->c_newsletter->domain_id); $tmp->setVar('ISSUEID', $this->c_issue->id); set_time_limit(60); for ($recipient = 0; $recipient < $count_to; $recipient++) { $error = ''; #### MAILTEST #### if (MAILTEST_ACTIVE && $count_to > 20) { $testemail = array('*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**', '*****@*****.**'); $to[$recipient]->email = $testemail[rand(0, 11)]; #$to[$recipient]->email = sprintf("*****@*****.**",rand(0,3)); } /* Personalize the recipient address. */ $to_address = $to[$recipient]->email; $to_name = $to[$recipient]->displayname; $textonly = $to[$recipient]->config == 'text'; //$email_class &= ( $textonly ) ? $email_text : $email_message; $email_class = $textonly ? $email_text : $email_message; if (XOX_MAILER_TYPE == 'pickup') { $email_class->pickup_file_prefix = sprintf("%s_%05d_%05d_%05d_%07s_%s_", date('YmdHis'), $this->c_issue->id, $this->mail_counter + 1, $to[$recipient]->uid, $to[$recipient]->mode_data, $to[$recipient]->mode_id == 1 ? 'N' : 'X'); } $email_class->SetEncodedEmailHeader("To", $to_address, $to_name); /* Do we really need to personalize the message body? * If not, let the class reuse the message body defined for the first recipient above. */ if (!$email_class->cache_body) { /* Create a personalized body part. */ $fingerprint = dechex($this->c_issue->id) . "g" . dechex($to[$recipient]->uid); if (MAILTEST_ACTIVE) { $fingerprint .= "g" . $to[$recipient]->mode_data; } $tmp->setVar('USERID', $fingerprint); $tmp->setVar('USEREMAIL', $to[$recipient]->email); $tmp->setVar('USERNAME', $to[$recipient]->displayname); $tmp->setVar('USERSALUT', $to[$recipient]->_details['gender']); $tmp->setVar('USERFNAME', $to[$recipient]->_details['firstname']); $tmp->setVar('USERLNAME', $to[$recipient]->_details['lastname']); $tmp->setVar('USERCOMPANY', $to[$recipient]->_details['company']); $tmp->setVar('USERSTREET', $to[$recipient]->_details['street']); $tmp->setVar('USERCOUNTRY', $to[$recipient]->_details['country']); $tmp->setVar('USERZIP', $to[$recipient]->_details['zip']); $tmp->setVar('USERCITY', $to[$recipient]->_details['city']); $tmp->setVar('USERTEL', $to[$recipient]->_details['telephone']); $tmp->setVar('USERFAX', $to[$recipient]->_details['fax']); $tmp->setVar('USERMOB', $to[$recipient]->_details['mobile']); if ($to[$recipient]->isExpert()) { $tmp->setVar('EXPERTS', '<td align="center" nowrap><a href="http://www.bay-as.de/index.php?id=189&fluid=' . $fingerprint . '" style="font-size:12px; font-family:Arial, Helvetica, sans-serif; text-decoration:none; color:#ffffff;"> <font color="white">BAYAS experts</font><b style="font-size:15px"> </b></a></td><td width="1" bgcolor="#ffffff"><img src="http://www.bay-as.de/fileadmin/images/punkt.gif" height="18" width="1"></td>'); $tmp->setVar('BAYPOINTS', $to[$recipient]->getBayPoints()); } else { $tmp->setVar('EXPERTS', ''); $tmp->setVar('BAYPOINTS', ''); } #$message="Hello ".strtok($to_name," ").",\n\nThis message is just to let you know that Manuel Lemos' e-mail sending class is working as expected for sending personalized messages.\n\nThank you,\n$from_name"; $tmp->parsed_template = $message; $email_class->CreateQuotedPrintableTextPart($tmp->show(true), "", $user_text_part); if (!$textonly) { $tmp->parsed_template = $html; $email_class->CreateQuotedPrintableHTMLPart($tmp->show(true), "", $user_html_part); } /* Make the personalized replace the initially empty part */ if (!$textonly) { $email_class->ReplacePart($text_part, $user_text_part); $email_class->ReplacePart($html_part, $user_html_part); } else { $email_class->ReplacePart($text_only_part, $user_text_part); } } /* Send the message checking for eventually acumulated errors */ #if ( !XOX_LOCAL_MODE ) { $this->error = $email_class->Send(); if ($this->mail_counter++ % 50 == 0) { set_time_limit(60); } $this->log->log(strlen($this->error), sprintf('Versand an: %05d %05d %05d %s [%s] : %s : %s', $this->mail_counter, $to[$recipient]->id, $to[$recipient]->uid, $to[$recipient]->displayname, $to[$recipient]->email, $to[$recipient]->mode_data . ($to[$recipient]->mode_id == 2 ? '*' : ' '), $this->error)); if (strlen($this->error)) { $this->mailerror++; //echo "\n\nERROR: $this->error<br>\n\n"; if ($this->mailerror >= $this->error_break && $this->mailerror == $this->mail_counter) { break; } } #} } /* When you are done with bulk mailing call the SetBulkMail function * again passing 0 to tell the all deliveries were done. */ $email_message->SetBulkMail(0); $email_text->SetBulkMail(0); if (strlen($this->error)) { return false; } return true; }
* * @(#) $Header: /opt2/ena/metal/mimemessage/test_personalized_bulk_mail.php,v 1.6 2005/02/16 04:04:03 mlemos Exp $ * */ require "email_message.php"; $from_name = getenv("USERNAME"); $from_address = getenv("USER") . "@" . getenv("HOSTNAME"); $reply_name = $from_name; $reply_address = $from_address; $reply_address = $from_address; $error_delivery_name = $from_name; $error_delivery_address = $from_address; /* Define recipient personalization data. Change it before testing. */ $to = array(array("address" => "*****@*****.**", "name" => "Peter Gabriel"), array("address" => "*****@*****.**", "name" => "Paul Simon"), array("address" => "*****@*****.**", "name" => "Mary Chain")); $subject = "Testing Manuel Lemos' MIME Email composition PHP class for sending personalized bulk mail"; $email_message = new email_message_class(); /* * For faster queueing use qmail... * * require_once("qmail_message.php"); * $email_message=new qmail_message_class; * * or sendmail in queue only delivery mode * * require_once("sendmail_message.php"); * $email_message=new sendmail_message_class; * $email_message->delivery_mode=SENDMAIL_DELIVERY_QUEUE; * * Always call the SetBulkMail function to hint the class to optimize * its behaviour to make deliveries to many users more efficient. */
if(!IsSet($multibyte_body)) $multibyte_body=$message; Header("Content-Type: text/html; charset=\"$charset\""); echo "<html>\n<head>\n<meta HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html; charset=$charset\" /><title>$title</title></head><body>"; echo "<h1><center>".$title."</center></h1>\n<hr />\n"; if(IsSet($send)) { $reply_name=$from_name; $reply_address=$from_address; $reply_address=$from_address; $error_delivery_name=$from_name; $error_delivery_address=$from_address; $email_message=new email_message_class; $email_message->default_charset=$charset; $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); /* Set the Return-Path header to define the envelope sender address to which bounced messages are delivered. If you are using Windows, you need to use the smtp_message_class to set the return-path address. */ if(defined("PHP_OS") && strcmp(substr(PHP_OS,0,3),"WIN")) $email_message->SetHeader("Return-Path",$error_delivery_address); $email_message->SetEncodedHeader("Subject",$multibyte_subject); $email_message->AddPlainTextPart($multibyte_body);
/* * Assign the $from_name and $from_address to your real sender name and * address or else the message may not be accepted. * */ $from_name = getenv("USERNAME"); $from_address = getenv("USER") . "@" . getenv("HOSTNAME"); $reply_name = $from_name; $reply_address = $from_address; $reply_address = $from_address; $error_delivery_name = $from_name; $error_delivery_address = $from_address; /* Define recipient personalization data. Change this before testing. */ $to = array(array("address" => "*****@*****.**", "name" => "Peter Gabriel", "balance" => 1234), array("address" => "*****@*****.**", "name" => "Paul Simon", "balance" => 567890), array("address" => "*****@*****.**", "name" => "Mary Chain", "balance" => -1234)); $subject = "Testing Manuel Lemos' MIME Email composition PHP class for sending personalized bulk mail using HTML and text template with the Smarty engine"; $email_message = new email_message_class(); /* * For faster queueing use qmail... * * require_once("qmail_message.php"); * $email_message=new qmail_message_class; * * or sendmail in queue only delivery mode * * require_once("sendmail_message.php"); * $email_message=new sendmail_message_class; * $email_message->delivery_mode=SENDMAIL_DELIVERY_QUEUE; * * Always call the SetBulkMail function to hint the class to optimize * its behaviour to make deliveries to many users more efficient. */
/** * TODO: dokumentado por sendu_konfirmilon * * $teksto - en tiu variablo ni metos la tekston de la mesagxo, * por ebligi montri gxin ankoraux en la retpagxo (krom * la dissendado). * * ### uzado: partrezultoj.php, AligxiloDankon.php ### */ function sendu_konfirmilon($partoprenanto, $partopreno, $renkontigxo, &$teksto) { $subject = "unua konfirmilo por la " . $renkontigxo->datoj[nomo]; $mesagxo = "### auxtomata mesagxo ###\n\n"; $from_name = "IS-Aligilo"; $from_address = "*****@*****.**"; // TODO: forigi retadreson $to_name = utf8_decode($partoprenanto->datoj[personanomo] . " " . $partoprenanto->datoj[nomo]); $to_address = $partoprenanto->datoj[retposxto]; $teksto = faru_1akonfirmilon($partoprenanto, $partopreno, $renkontigxo); $mesagxo .= $teksto; $email_message = new email_message_class(); $email_message->default_charset = "UTF-8"; if (!strcmp($error = $email_message->SetEncodedEmailHeader("To", $to_address, $to_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("From", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("Reply-To", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedEmailHeader("Bcc", "*****@*****.**", "Paul Ebermann"), "") && !strcmp($error = $email_message->SetEncodedHeader("Errors-To", $from_address, $from_name), "") && !strcmp($error = $email_message->SetEncodedHeader("Subject", $subject), "") && !strcmp($error = $email_message->AddQuotedPrintableTextPart($email_message->WrapText($mesagxo)), "")) { $error = $email_message->Send(); } if ($error) { erareldono($error); exit; } }