updated phpMailer-Class to version 5.1 (PHP5/PHP6), fixes #35

This commit is contained in:
Michael Kaufmann (d00p)
2010-03-03 08:51:13 +00:00
parent a0c557c405
commit a6909a8cec
9 changed files with 3224 additions and 3469 deletions

View File

@@ -622,23 +622,23 @@ if($page == 'customers'
$result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'createcustomer_mailbody\''); $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($def_language) . '\' AND `templategroup`=\'mails\' AND `varname`=\'createcustomer_mailbody\'');
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['createcustomer']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['createcustomer']['mailbody']), $replace_arr));
$mail->From = $userinfo['email']; $_mailerror = false;
$mail->FromName = $userinfo['name']; try {
$mail->Subject = $mail_subject; $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
$mail->Body = $mail_body; $mail->Subject = $mail_subject;
$mail->AddAddress($email, getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company))); $mail->AltBody = $mail_body;
$mail->MsgHTML($mail_body);
if(!$mail->Send()) $mail->AddAddress($email, getCorrectUserSalutation(array('firstname' => $firstname, 'name' => $name, 'company' => $company)));
{ $mail->Send();
if($mail->ErrorInfo != '') } catch(phpmailerException $e) {
{ $mailerr_msg = $e->errorMessage();
$mailerr_msg = $mail->ErrorInfo; $_mailerror = true;
} } catch (Exception $e) {
else $mailerr_msg = $e->getMessage();
{ $_mailerror = true;
$mailerr_msg = $email; }
}
if ($_mailerror) {
$log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $log->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $email); standard_error('errorsendingmail', $email);
} }

View File

@@ -427,23 +427,24 @@ elseif($page == 'accounts')
$mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success']['subject']), $replace_arr)); $mail_subject = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success']['subject']), $replace_arr));
$result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_mailbody\''); $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_mailbody\'');
$mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success']['mailbody']), $replace_arr));
$mail->From = $admin['email'];
$mail->FromName = getCorrectUserSalutation($admin); $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($admin['email'], getCorrectUserSalutation($admin));
$mail->AddAddress($email_full, getCorrectUserSalutation($userinfo)); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
if(!$mail->Send()) $mail->MsgHTML($mail_body);
{ $mail->AddAddress($email_full, getCorrectUserSalutation($userinfo));
if($mail->ErrorInfo != '') $mail->Send();
{ } catch(phpmailerException $e) {
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $e->errorMessage();
} $_mailerror = true;
else } catch (Exception $e) {
{ $mailerr_msg = $e->getMessage();
$mailerr_msg = $email; $_mailerror = true;
} }
if ($_mailerror) {
$log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error('errorsendingmail', $email); standard_error('errorsendingmail', $email);
} }
@@ -457,23 +458,24 @@ elseif($page == 'accounts')
$mail_subject = replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success_alternative']['subject']), $replace_arr); $mail_subject = replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success_alternative']['subject']), $replace_arr);
$result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_alternative_mailbody\''); $result = $db->query_first('SELECT `value` FROM `' . TABLE_PANEL_TEMPLATES . '` WHERE `adminid`=\'' . (int)$userinfo['adminid'] . '\' AND `language`=\'' . $db->escape($userinfo['def_language']) . '\' AND `templategroup`=\'mails\' AND `varname`=\'pop_success_alternative_mailbody\'');
$mail_body = replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success_alternative']['mailbody']), $replace_arr); $mail_body = replace_variables((($result['value'] != '') ? $result['value'] : $lng['mails']['pop_success_alternative']['mailbody']), $replace_arr);
$mail->From = $admin['email'];
$mail->FromName = getCorrectUserSalutation($admin); $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($admin['email'], getCorrectUserSalutation($admin));
$mail->AddAddress($idna_convert->encode($alternative_email), getCorrectUserSalutation($userinfo)); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
if(!$mail->Send()) $mail->MsgHTML($mail_body);
{ $mail->AddAddress($idna_convert->encode($alternative_email), getCorrectUserSalutation($userinfo));
if($mail->ErrorInfo != '') $mail->Send();
{ } catch(phpmailerException $e) {
$mailerr_msg = $mail->ErrorInfo; $mailerr_msg = $e->errorMessage();
} $_mailerror = true;
else } catch (Exception $e) {
{ $mailerr_msg = $e->getMessage();
$mailerr_msg = $alternative_email; $_mailerror = true;
} }
if ($_mailerror) {
$log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $log->logAction(USR_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error(array('errorsendingmail', $alternative_email)); standard_error(array('errorsendingmail', $alternative_email));
} }

View File

@@ -258,23 +258,23 @@ if($action == 'forgotpwd')
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings); $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
$rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!"); $rstlog->logAction(USR_ACTION, LOG_WARNING, "Password for user '" . $user['loginname'] . "' has been reset!");
$body = strtr($lng['pwdreminder']['body'], array('%s' => $user['firstname'] . ' ' . $user['name'], '%p' => $password)); $body = strtr($lng['pwdreminder']['body'], array('%s' => $user['firstname'] . ' ' . $user['name'], '%p' => $password));
$mail->From = $settings['panel']['adminmail'];
$mail->FromName = 'Froxlor'; $_mailerror = false;
$mail->Subject = $lng['pwdreminder']['subject']; try {
$mail->Body = $body; $mail->Subject = $lng['pwdreminder']['subject'];
$mail->AddAddress($user['email'], $user['firstname'] . ' ' . $user['name']); $mail->AltBody = $body;
$mail->MsgHTML($body);
if(!$mail->Send()) $mail->AddAddress($user['email'], $user['firstname'] . ' ' . $user['name']);
{ $mail->Send();
if($mail->ErrorInfo != '') } catch(phpmailerException $e) {
{ $mailerr_msg = $e->errorMessage();
$mailerr_msg = $mail->ErrorInfo; $_mailerror = true;
} } catch (Exception $e) {
else $mailerr_msg = $e->getMessage();
{ $_mailerror = true;
$mailerr_msg = $email; }
}
if ($_mailerror) {
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings); $rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'password_reset'), $db, $settings);
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg); $rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
redirectTo('index.php', Array('showmessage' => '4'), true); redirectTo('index.php', Array('showmessage' => '4'), true);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -286,14 +286,25 @@ class ticket
if($customerid != - 1) if($customerid != - 1)
{ {
$mail->From = $this->settings['ticket']['noreply_email']; $_mailerror = false;
$mail->FromName = $this->settings['ticket']['noreply_name']; try {
$mail->Subject = $mail_subject; $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
$mail->Body = $mail_body; $mail->Subject = $mail_subject;
$mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']); $mail->AltBody = $mail_body;
$mail->MsgHTML($mail_body);
if(!$mail->Send()) $mail->AddAddress($usr['email'], $usr['firstname'] . ' ' . $usr['name']);
{ $mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings);
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error(array('errorsendingmail', $usr['email'])); standard_error(array('errorsendingmail', $usr['email']));
} }
@@ -302,14 +313,26 @@ class ticket
else else
{ {
$admin = $this->db->query_first("SELECT `name`, email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$this->userinfo['adminid'] . "'"); $admin = $this->db->query_first("SELECT `name`, email` FROM `" . TABLE_PANEL_ADMINS . "` WHERE `adminid`='" . (int)$this->userinfo['adminid'] . "'");
$mail->From = $this->settings['ticket']['noreply_email'];
$mail->FromName = $this->settings['ticket']['noreply_name']; $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($this->settings['ticket']['noreply_email'], $this->settings['ticket']['noreply_name']);
$mail->AddAddress($admin['email'], $admin['name']); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
if(!$mail->Send()) $mail->MsgHTML($mail_body);
{ $mail->AddAddress($admin['email'], $admin['name']);
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if ($_mailerror) {
$rstlog = FroxlorLogger::getInstanceOf(array('loginname' => 'ticket_class'), $this->db, $this->settings);
$rstlog->logAction(ADM_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
standard_error(array('errorsendingmail', $admin['email'])); standard_error(array('errorsendingmail', $admin['email']));
} }

View File

@@ -416,6 +416,6 @@ if($page == '')
*/ */
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->From = $settings['panel']['adminmail']; $mail->SetFrom($settings['panel']['adminmail'], 'Froxlor Administrator');
?> ?>

View File

@@ -209,28 +209,25 @@ if($db->num_rows($result) > 0)
continue; continue;
} }
//send mail with mailer class $_mailerror = false;
$mail->From = $to; try {
$mail->FromName = $to; $mail->SetFrom($to, $to);
$mail->Subject = $row['subject']; $mail->AddReplyTo($to, $to);
$mail->Body = html_entity_decode($message); $mail->Subject = $row['subject'];
$mail->AddAddress($from, $from); $mail->AltBody = $message;
$mail->AddCustomHeader('Precedence: bulk'); $mail->MsgHTML(html_entity_decode($message));
$mail->AddAddress($from, $from);
// set correct return path $mail->AddCustomHeader('Precedence: bulk');
$mail->Sender = $to; $mail->Send();
} catch(phpmailerException $e) {
if(!$mail->Send()) $mailerr_msg = $e->errorMessage();
{ $_mailerror = true;
if($mail->ErrorInfo != '') } catch (Exception $e) {
{ $mailerr_msg = $e->getMessage();
$mailerr_msg = $mail->ErrorInfo; $_mailerror = true;
} }
else
{ if ($_mailerror) {
$mailerr_msg = $from;
}
$cronlog->logAction(CRON_ACTION, LOG_WARNING, "Error sending autoresponder mail: " . $mailerr_msg); $cronlog->logAction(CRON_ACTION, LOG_WARNING, "Error sending autoresponder mail: " . $mailerr_msg);
} }

View File

@@ -26,7 +26,7 @@ $yesterday = time() - (60 * 60 * 24);
require (dirname(__FILE__) . '/../lib/class.phpmailer.php'); require (dirname(__FILE__) . '/../lib/class.phpmailer.php');
$mail = new PHPMailer(); $mail = new PHPMailer();
$mail->From = $settings['panel']['adminmail']; $mail->SetFrom($settings['panel']['adminmail'], 'Froxlor Administrator');
// Warn the customers at 90% traffic-usage // Warn the customers at 90% traffic-usage
@@ -82,15 +82,26 @@ while($row = $db->fetch_array($result))
AND `templategroup`='mails' AND `templategroup`='mails'
AND `varname`='trafficninetypercent_mailbody'"); AND `varname`='trafficninetypercent_mailbody'");
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficninetypercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficninetypercent']['mailbody']), $replace_arr));
$mail->From = $row['adminmail'];
$mail->FromName = $row['adminname']; $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($row['adminmail'], $row['adminname']);
$mail->AddAddress($row['email'], $row['firstname'] . ' ' . $row['name']); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_body);
$mail->AddAddress($row['email'], $row['firstname'] . ' ' . $row['name']);
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if(!$mail->Send()) if($_mailerror)
{ {
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mail->ErrorInfo); $cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $_mailerror);
standard_error('errorsendingmail', $row["email"]); standard_error('errorsendingmail', $row["email"]);
} }
@@ -150,15 +161,25 @@ while($row = $db->fetch_array($result))
AND `templategroup`='mails' AND `templategroup`='mails'
AND `varname`='trafficninetypercent_mailbody'"); AND `varname`='trafficninetypercent_mailbody'");
$mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficninetypercent']['mailbody']), $replace_arr)); $mail_body = html_entity_decode(replace_variables((($result2['value'] != '') ? $result2['value'] : $lng['mails']['trafficninetypercent']['mailbody']), $replace_arr));
$mail->From = $row['email'];
$mail->FromName = $row['firstname'] . " " . $row['name']; $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($row['email'], $row['firstname'] . " " . $row['name']);
$mail->AddAddress($row['email'], $row['name']); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_body);
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if(!$mail->Send()) if ($_mailerror) {
{ $cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mail->ErrorInfo);
standard_error('errorsendingmail', $row["email"]); standard_error('errorsendingmail', $row["email"]);
} }
@@ -189,15 +210,25 @@ while($row = $db->fetch_array($result))
$mail_body.= '---------------------------------------------' . "\n"; $mail_body.= '---------------------------------------------' . "\n";
$mail_body.= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-12d', $row['traffic_used_total']) . ' (' . sprintf('%00.3f%%', (($row['traffic_used_total'] * 100) / $row['traffic'])) . ') ' . $row['traffic'] . "\n"; $mail_body.= sprintf('%-15s', $row['loginname']) . ' ' . sprintf('%-12d', $row['traffic_used_total']) . ' (' . sprintf('%00.3f%%', (($row['traffic_used_total'] * 100) / $row['traffic'])) . ') ' . $row['traffic'] . "\n";
$mail->From = $row['email'];
$mail->FromName = $row['name']; $_mailerror = false;
$mail->Subject = $mail_subject; try {
$mail->Body = $mail_body; $mail->SetFrom($row['email'], $row['name']);
$mail->AddAddress($row['email'], $row['name']); $mail->Subject = $mail_subject;
$mail->AltBody = $mail_body;
$mail->MsgHTML($mail_body);
$mail->AddAddress($row['email'], $row['name']);
$mail->Send();
} catch(phpmailerException $e) {
$mailerr_msg = $e->errorMessage();
$_mailerror = true;
} catch (Exception $e) {
$mailerr_msg = $e->getMessage();
$_mailerror = true;
}
if(!$mail->Send()) if ($_mailerror) {
{ $cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mailerr_msg);
$cronlog->logAction(CRON_ACTION, LOG_ERR, "Error sending mail: " . $mail->ErrorInfo);
standard_error('errorsendingmail', $row["email"]); standard_error('errorsendingmail', $row["email"]);
} }