1
0

Added additional error handling.

This commit is contained in:
rWatcher 2011-06-01 14:50:12 -04:00
parent 9316a4eaef
commit 5d7d027e75
2 changed files with 30 additions and 4 deletions

View File

@ -97,12 +97,19 @@ class Sendmail_Core {
// Gallery Sendmail script. Outside of this function,
// no other changes were made.
require(module::get_var("phpmailer", "phpmailer_path"));
// Make sure phpmailer_path is valid.
if(!file_exists(module::get_var("phpmailer", "phpmailer_path"))) {
Kohana_Log::add("error", wordwrap("File Not Found: " . module::get_var("phpmailer", "phpmailer_path")));
return false;
}
require_once(module::get_var("phpmailer", "phpmailer_path"));
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = module::get_var("phpmailer", "smtp_server");
$mail->Port = module::get_var("phpmailer", "smtp_port");
$mail->SMTPDebug = 1;
if (module::get_var("phpmailer", "smtp_login") != "") {
$mail->SMTPAuth = true;
@ -133,6 +140,12 @@ class Sendmail_Core {
$mail->Subject = $subject;
$mail->Body = $message;
return $mail->Send();
// Log any errors.
if (!$mail->Send()) {
Kohana_Log::add("error", wordwrap($mail->ErrorInfo));
return false;
} else {
return true;
}
}
}

View File

@ -97,12 +97,19 @@ class Sendmail_Core {
// Gallery Sendmail script. Outside of this function,
// no other changes were made.
require(module::get_var("phpmailer", "phpmailer_path"));
// Make sure phpmailer_path is valid.
if(!file_exists(module::get_var("phpmailer", "phpmailer_path"))) {
Kohana_Log::add("error", wordwrap("File Not Found: " . module::get_var("phpmailer", "phpmailer_path")));
return false;
}
require_once(module::get_var("phpmailer", "phpmailer_path"));
$mail = new PHPMailer();
$mail->IsSMTP();
$mail->Host = module::get_var("phpmailer", "smtp_server");
$mail->Port = module::get_var("phpmailer", "smtp_port");
$mail->SMTPDebug = 1;
if (module::get_var("phpmailer", "smtp_login") != "") {
$mail->SMTPAuth = true;
@ -133,6 +140,12 @@ class Sendmail_Core {
$mail->Subject = $subject;
$mail->Body = $message;
return $mail->Send();
// Log any errors.
if (!$mail->Send()) {
Kohana_Log::add("error", wordwrap($mail->ErrorInfo));
return false;
} else {
return true;
}
}
}