[ Index ] |
|
Code source de e107 0.7.8 |
1 <?php 2 /* 3 + ----------------------------------------------------------------------------+ 4 | e107 website system 5 | 6 | ©Steve Dunstan 2001-2002 7 | http://e107.org 8 | jalist@e107.org 9 | 10 | Released under the terms and conditions of the 11 | GNU General Public License (http://gnu.org). 12 | 13 | $Source: /cvsroot/e107/e107_0.7/e107_handlers/mail.php,v $ 14 | $Revision: 1.39 $ 15 | $Date: 2006/12/30 18:55:34 $ 16 | $Author: e107steved $ 17 +----------------------------------------------------------------------------+ 18 */ 19 20 if (!defined('e107_INIT')) { exit; } 21 22 if(is_readable(THEME."email_template.php")) 23 { 24 require_once(THEME."email_template.php"); 25 } 26 else 27 { 28 require_once(e_THEME."templates/email_template.php"); 29 } 30 31 if(isset($EMAIL_HEADER) && isset($EMAIL_FOOTER) && is_object($tp)){ 32 $EMAIL_HEADER = $tp->parseTemplate($EMAIL_HEADER); 33 $EMAIL_FOOTER = $tp->parseTemplate($EMAIL_FOOTER); 34 } 35 /* 36 Please note that mailed attachments have been found to be corrupted using php 4.3.3 37 php 4.3.6 does NOT have this problem. 38 */ 39 // Comment out the line below if you have trouble with some people not receiving emails. 40 // e107_ini_set(sendmail_path, "/usr/sbin/sendmail -t -f ".$pref['siteadminemail']); 41 42 function sendemail($send_to, $subject, $message, $to_name, $send_from, $from_name, $attachments='', $Cc='', $Bcc='', $returnpath='', $returnreceipt='',$inline ="") { 43 global $pref,$mailheader_e107id; 44 45 require_once(e_HANDLER."phpmailer/class.phpmailer.php"); 46 47 $mail = new PHPMailer(); 48 49 if($mailheader_e107id){ 50 $mail->AddCustomHeader("X-e107-id: {$mailheader_e107id}"); 51 } 52 53 if ($pref['mailer']== 'smtp') { 54 55 if(isset($pref['smtp_pop3auth']) && $pref['smtp_pop3auth']){ 56 // http://www.corephp.co.uk/archives/18-POP-before-SMTP-Authentication-for-PHPMailer.html 57 require_once(e_HANDLER."phpmailer/class.pop3.php"); 58 $pop = new POP3(); 59 $pop->Authorise($pref['smtp_server'], 110, 30, $pref['smtp_username'], $pref['smtp_password'], 1); 60 } 61 62 $mail->Mailer = "smtp"; 63 $mail->SMTPKeepAlive = FALSE; 64 $mail->Host = $pref['smtp_server']; 65 if($pref['smtp_username'] && $pref['smtp_password']){ 66 $mail->SMTPAuth = (isset($pref['smtp_pop3auth']) && $pref['smtp_pop3auth']) ? FALSE : TRUE; 67 $mail->Username = $pref['smtp_username']; 68 $mail->Password = $pref['smtp_password']; 69 $mail->PluginDir = e_HANDLER."phpmailer/"; 70 } 71 72 } elseif ($pref['mailer']== 'sendmail'){ 73 $mail->Mailer = "sendmail"; 74 $mail->Sendmail = ($pref['sendmail']) ? $pref['sendmail'] : "/usr/sbin/sendmail -t -i -r ".$pref['siteadminemail']; 75 } else { 76 $mail->Mailer = "mail"; 77 } 78 79 $to_name = ($to_name) ? $to_name: $send_to; 80 81 $mail->CharSet = CHARSET; 82 $mail->From = ($send_from)? $send_from: $pref['siteadminemail']; 83 $mail->FromName = ($from_name)? $from_name: $pref['siteadmin']; 84 $mail->Subject = $subject; 85 $mail->SetLanguage("en",e_HANDLER."phpmailer/language/"); 86 87 $lb = "\n"; 88 89 90 // Clean up the HTML. == 91 92 if (preg_match('/<(font|br|a|img|b)/i', $message)) { 93 $Html = $message; // Assume html if it begins with one of these tags 94 } else { 95 $Html = htmlspecialchars($message); 96 $Html = preg_replace('%(http|ftp|https)(://\S+)%', '<a href="\1\2">\1\2</a>', $Html); 97 $Html = preg_replace('/([[:space:]()[{}])(www.[-a-zA-Z0-9@:%_\+.~#?&\/\/=]+)/i', '\\1<a href="http://\\2">\\2</a>', $Html); 98 $Html = preg_replace('/([_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3})/i', '<a href="mailto:\\1">\\1</a>', $Html); 99 $Html = str_replace("\r","\n",$Html); // Handle alternative newline characters 100 $Html = str_replace("\n", "<br />\n", $Html); 101 } 102 if (strpos($message,"</style>") !== FALSE){ 103 $text = strstr($message,"</style>"); 104 }else{ 105 $text = $message; 106 } 107 $text = str_replace("<br />", "\n", $text); 108 $text = strip_tags(str_replace("<br>", "\n", $text)); 109 110 $mail->Body = $Html; //Main message is HTML 111 $mail->IsHTML(TRUE); 112 $mail->AltBody = $text; //Include regular plaintext as well 113 114 115 $tmp = explode(",",$send_to); 116 foreach($tmp as $adr){ 117 $mail->AddAddress($adr, $to_name); 118 } 119 120 121 if ($attachments){ 122 if (is_array($attachments)) { 123 foreach($attachments as $attach){ 124 if(is_readable($attach)){ 125 $mail->AddAttachment($attach, basename($attach),"base64",mime_content_type($attach)); 126 } 127 } 128 }else{ 129 if(is_readable($attachments)){ 130 $mail->AddAttachment($attachments, basename($attachments),"base64",mime_content_type($attachments)); 131 } 132 } 133 } 134 135 if($inline){ 136 $tmp = explode(",",$inline); 137 foreach($tmp as $inline_img){ 138 if(is_readable($inline_img) && !is_dir($inline_img)){ 139 $mail->AddEmbeddedImage($inline_img, md5($inline_img), basename($inline_img),"base64",mime_content_type($inline_img)); 140 } 141 } 142 } 143 144 145 if($Cc){ 146 if($mail->Mailer == "mail"){ 147 $mail->AddCustomHeader("Cc: {$Cc}"); 148 }else{ 149 $tmp = explode(",",$Cc); 150 foreach($tmp as $addc){ 151 $mail->AddCC($addc); 152 } 153 } 154 } 155 156 if($Bcc){ 157 if($mail->Mailer == "mail"){ 158 $mail->AddCustomHeader("Bcc: {$Bcc}"); 159 }else{ 160 $tmp = explode(",",$Bcc); 161 foreach($tmp as $addbc){ 162 $mail->AddBCC($addbc); 163 } 164 } 165 } 166 167 if (isset($returnpath) && ($returnpath != "")) 168 { // Passed parameter overrides any system default 169 $mail->Sender = $returnpath; 170 } 171 elseif($pref['mail_bounce_email'] !=''){ 172 $mail->Sender = $pref['mail_bounce_email']; 173 } 174 175 if (!$mail->Send()) { 176 // echo "There has been a mail error sending to " . $row["email"] . "<br>"; 177 return FALSE; 178 // Clear all addresses and attachments for next loop 179 $mail->ClearAddresses(); 180 $mail->ClearAttachments(); 181 } else { 182 // Clear all addresses and attachments for next loop 183 $mail->ClearAddresses(); 184 $mail->ClearAttachments(); 185 return TRUE; 186 } 187 188 } 189 190 /* Deprecated. 191 Use mail_validation_class.php instead. 192 function validatemail($Email) { 193 194 } 195 */ 196 197 198 199 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Sun Apr 1 01:23:32 2007 | par Balluche grâce à PHPXref 0.7 |