| ... | ... |
@@ -29,7 +29,7 @@ if(!defined("_CHARSET")) exit( );
|
| 29 | 29 |
|
| 30 | 30 |
function sendemail($to_name,$to_email,$from_name,$from_email,$subject,$message,$type="plain",$cc="",$bcc="") {
|
| 31 | 31 |
|
| 32 |
- global $language, $smtp_host, $smtp_username, $smtp_password, $siteemail; |
|
| 32 |
+ global $language, $smtp_host, $smtp_username, $smtp_password, $smtp_port, $smtp_secure, $smtp_debug, $siteemail; |
|
| 33 | 33 |
|
| 34 | 34 |
// Check for hackers and spammers and bad input |
| 35 | 35 |
if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
| ... | ... |
@@ -64,12 +64,22 @@ function sendemail($to_name,$to_email,$from_name,$from_email,$subject,$message,$ |
| 64 | 64 |
if(!$smtp_host) {
|
| 65 | 65 |
$mail->IsMail( ); |
| 66 | 66 |
} |
| 67 |
- else {
|
|
| 67 |
+ else {
|
|
| 68 | 68 |
$mail->IsSMTP( ); |
| 69 | 69 |
$mail->Host = $smtp_host; |
| 70 | 70 |
$mail->SMTPAuth = true; |
| 71 | 71 |
$mail->Username = $smtp_username; |
| 72 | 72 |
$mail->Password = $smtp_password; |
| 73 |
+ // Apply transport settings only when configured; otherwise leave PHPMailer |
|
| 74 |
+ // defaults (and SMTPAutoTLS) in place. !empty() avoids 8.x warnings on |
|
| 75 |
+ // not-yet-migrated installs where these globals are undefined. |
|
| 76 |
+ if (!empty($smtp_port)) $mail->Port = (int) $smtp_port; |
|
| 77 |
+ if (!empty($smtp_secure)) $mail->SMTPSecure = $smtp_secure; // '', 'tls', 'ssl' |
|
| 78 |
+ // Optional handshake debugging, off unless $smtp_debug is set. Routed to the PHP error log. |
|
| 79 |
+ if(!empty($smtp_debug)) {
|
|
| 80 |
+ $mail->SMTPDebug = 2; |
|
| 81 |
+ $mail->Debugoutput = function($str, $level) { error_log("eFiction SMTP debug [$level]: ".trim($str)); };
|
|
| 82 |
+ } |
|
| 73 | 83 |
} |
| 74 | 84 |
$mail->CharSet = _CHARSET; |
| 75 | 85 |
$mail->From = $siteemail; |
| ... | ... |
@@ -97,10 +107,11 @@ function sendemail($to_name,$to_email,$from_name,$from_email,$subject,$message,$ |
| 97 | 107 |
$mail->Subject = $subject; |
| 98 | 108 |
$mail->Body = $message; |
| 99 | 109 |
if(!$mail->Send()) {
|
| 100 |
- $mail->ErrorInfo; |
|
| 110 |
+ $errorinfo = $mail->ErrorInfo; |
|
| 111 |
+ error_log("eFiction sendemail failed for ".$to_email.": ".$errorinfo);
|
|
| 101 | 112 |
$mail->ClearAllRecipients(); |
| 102 | 113 |
$mail->ClearReplyTos(); |
| 103 |
- return $mail->ErrorInfo; |
|
| 114 |
+ return false; |
|
| 104 | 115 |
} else {
|
| 105 | 116 |
$mail->ClearAllRecipients(); |
| 106 | 117 |
$mail->ClearReplyTos(); |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,111 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+// ---------------------------------------------------------------------- |
|
| 4 |
+// eFiction 3.2 |
|
| 5 |
+// Copyright (c) 2007 by Tammy Keefer |
|
| 6 |
+// Valid HTML 4.01 Transitional |
|
| 7 |
+// Based on eFiction 1.1 |
|
| 8 |
+// Copyright (C) 2003 by Rebecca Smallwood. |
|
| 9 |
+// http://efiction.sourceforge.net/ |
|
| 10 |
+// ---------------------------------------------------------------------- |
|
| 11 |
+// LICENSE |
|
| 12 |
+// |
|
| 13 |
+// This program is free software; you can redistribute it and/or |
|
| 14 |
+// modify it under the terms of the GNU General Public License (GPL) |
|
| 15 |
+// as published by the Free Software Foundation; either version 2 |
|
| 16 |
+// of the License, or (at your option) any later version. |
|
| 17 |
+// |
|
| 18 |
+// This program is distributed in the hope that it will be useful, |
|
| 19 |
+// but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
| 20 |
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
| 21 |
+// GNU General Public License for more details. |
|
| 22 |
+// |
|
| 23 |
+// To read the license please visit http://www.gnu.org/copyleft/gpl.html |
|
| 24 |
+// ---------------------------------------------------------------------- |
|
| 25 |
+ |
|
| 26 |
+if(!defined("_CHARSET")) exit( );
|
|
| 27 |
+ |
|
| 28 |
+ |
|
| 29 |
+ |
|
| 30 |
+function sendemail($to_name,$to_email,$from_name,$from_email,$subject,$message,$type="plain",$cc="",$bcc="") {
|
|
| 31 |
+ |
|
| 32 |
+ global $language, $smtp_host, $smtp_username, $smtp_password, $siteemail; |
|
| 33 |
+ |
|
| 34 |
+ // Check for hackers and spammers and bad input |
|
| 35 |
+ if(!isset($_SERVER['HTTP_USER_AGENT'])) return false; |
|
| 36 |
+ $badStrings = array("Content-Type:", "MIME-Version:", "Content-Transfer-Encoding:", "bcc:", "cc:");
|
|
| 37 |
+ $checks = array($to_name, $to_email, $from_name, $from_email, $subject); |
|
| 38 |
+ foreach($checks as $check) {
|
|
| 39 |
+ foreach($badStrings as $bad){
|
|
| 40 |
+ if(strpos($check, $bad) !== false) return false; // Spammer |
|
| 41 |
+ } |
|
| 42 |
+ } |
|
| 43 |
+ unset($bad, $badStrings, $checks, $check); |
|
| 44 |
+ if (!((bool) preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', $to_email))) return false; // Bad e-mail
|
|
| 45 |
+ if (!((bool) preg_match('/^[-_a-z0-9\'+*$^&%=~!?{}]++(?:\.[-_a-z0-9\'+*$^&%=~!?{}]+)*+@(?:(?![-.])[-a-z0-9.]+(?<![-.])\.[a-z]{2,6}|\d{1,3}(?:\.\d{1,3}){3})(?::\d++)?$/iD', $from_email))) {
|
|
| 46 |
+ echo "bad email"; |
|
| 47 |
+ return false; // Bad e-mail |
|
| 48 |
+ } |
|
| 49 |
+ if (empty($_SERVER['HTTP_USER_AGENT']) || !$_SERVER['REQUEST_METHOD'] == "POST") return false; // Spammer |
|
| 50 |
+ $subject = descript(strip_tags($subject)); |
|
| 51 |
+ $message = descript($message); |
|
| 52 |
+ // End paranoia |
|
| 53 |
+ |
|
| 54 |
+ // Try to determine the right $type setting |
|
| 55 |
+ if(strpos($message, "<br>") || strpos($message, "</p>") || strpos($message, "<br />") || strpos($message, "<br>") || strpos($message, "<a href")) $type = "html"; |
|
| 56 |
+ |
|
| 57 |
+ require_once(_BASEDIR."includes/PHPMailerAutoload.php"); |
|
| 58 |
+ $mail = new PHPMailer; |
|
| 59 |
+ if(file_exists(_BASEDIR."languages/mailer/phpmailer.lang-".$language.".php")) |
|
| 60 |
+ $mail->SetLanguage($language, _BASEDIR."languages/mailer/"); |
|
| 61 |
+ else |
|
| 62 |
+ $mail->SetLanguage("en", _BASEDIR."languages/mailer/");
|
|
| 63 |
+ |
|
| 64 |
+ if(!$smtp_host) {
|
|
| 65 |
+ $mail->IsMail( ); |
|
| 66 |
+ } |
|
| 67 |
+ else {
|
|
| 68 |
+ $mail->IsSMTP( ); |
|
| 69 |
+ $mail->Host = $smtp_host; |
|
| 70 |
+ $mail->SMTPAuth = true; |
|
| 71 |
+ $mail->Username = $smtp_username; |
|
| 72 |
+ $mail->Password = $smtp_password; |
|
| 73 |
+ } |
|
| 74 |
+ $mail->CharSet = _CHARSET; |
|
| 75 |
+ $mail->From = $siteemail; |
|
| 76 |
+ $mail->FromName = $from_name; |
|
| 77 |
+ $mail->AddAddress($to_email, $to_name); |
|
| 78 |
+ $mail->AddReplyTo($from_email, $from_name); |
|
| 79 |
+ if($cc) {
|
|
| 80 |
+ $cc = explode(", ", $cc);
|
|
| 81 |
+ foreach ($cc as $ccaddress) {
|
|
| 82 |
+ $mail->AddCC($ccaddress); |
|
| 83 |
+ } |
|
| 84 |
+ } |
|
| 85 |
+ if ($bcc) {
|
|
| 86 |
+ $bcc = explode(", ", $bcc);
|
|
| 87 |
+ foreach ($bcc as $bccaddress) {
|
|
| 88 |
+ $mail->AddBCC($bccaddress); |
|
| 89 |
+ } |
|
| 90 |
+ } |
|
| 91 |
+ if ($type == "plain") {
|
|
| 92 |
+ $mail->IsHTML(false); |
|
| 93 |
+ } else {
|
|
| 94 |
+ $mail->IsHTML(true); |
|
| 95 |
+ } |
|
| 96 |
+ |
|
| 97 |
+ $mail->Subject = $subject; |
|
| 98 |
+ $mail->Body = $message; |
|
| 99 |
+ if(!$mail->Send()) {
|
|
| 100 |
+ $mail->ErrorInfo; |
|
| 101 |
+ $mail->ClearAllRecipients(); |
|
| 102 |
+ $mail->ClearReplyTos(); |
|
| 103 |
+ return $mail->ErrorInfo; |
|
| 104 |
+ } else {
|
|
| 105 |
+ $mail->ClearAllRecipients(); |
|
| 106 |
+ $mail->ClearReplyTos(); |
|
| 107 |
+ return true; |
|
| 108 |
+ } |
|
| 109 |
+ |
|
| 110 |
+} |
|
| 111 |
+?> |
|
| 0 | 112 |
\ No newline at end of file |