diff --git a/system/bin/send_email.php b/system/bin/send_email.php index ee969522..bac3aa6f 100644 --- a/system/bin/send_email.php +++ b/system/bin/send_email.php @@ -54,7 +54,7 @@ if(strlen($subject) > 255) { } if(!_mail($email_account_name, $subject, $message)) { - echo 'Error while sending mail: ' . $mailer->ErrorInfo . PHP_EOL; + echo 'An error occurred while sending email. More info can be found in system/logs/mailer-error.log'; exit(6); } diff --git a/system/functions.php b/system/functions.php index 87efbff6..8db4a727 100644 --- a/system/functions.php +++ b/system/functions.php @@ -878,7 +878,14 @@ function _mail($to, $subject, $body, $altBody = '', $add_html_tags = true) $mailer->AltBody = strip_tags(preg_replace('//','$2', $body)) . "\n" . $signature_plain; } - return $mailer->Send(); + ob_start(); + if(!$mailer->Send()) { + log_append('mailer-error.log', PHP_EOL . $mailer->ErrorInfo . PHP_EOL . ob_get_clean()); + return false; + } + + ob_end_clean(); + return true; } function convert_bytes($size) diff --git a/system/pages/account/change_password.php b/system/pages/account/change_password.php index 74934d67..37ff7f32 100644 --- a/system/pages/account/change_password.php +++ b/system/pages/account/change_password.php @@ -69,7 +69,7 @@ else if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Changed password", $mailBody)) $message = '
Your new password were send on email address '.$account_logged->getEMail().'.'; else - $message = '

An error occorred while sending email with password:
' . $mailer->ErrorInfo . '

'; + $message = '

An error occurred while sending email. For Admin: More info can be found in system/logs/mailer-error.log

'; } $twig->display('success.html.twig', array( diff --git a/system/pages/account/register.php b/system/pages/account/register.php index 72da9ab8..bfb69ee1 100644 --- a/system/pages/account/register.php +++ b/system/pages/account/register.php @@ -31,7 +31,7 @@ if(isset($_POST['registeraccountsave']) && $_POST['registeraccountsave'] == "1") if(_mail($account_logged->getEMail(), $config['lua']['serverName']." - Recovery Key", $mailBody)) $message = '
Your recovery key were send on email address '.$account_logged->getEMail().'.'; else - $message = '

An error occorred while sending email with recovery key! You will not receive e-mail with this key. Error:
' . $mailer->ErrorInfo . '

'; + $message = '

An error occurred while sending email. For Admin: More info can be found in system/logs/mailer-error.log

'; } $twig->display('success.html.twig', array( 'title' => 'Account Registered', diff --git a/system/pages/account/register_new.php b/system/pages/account/register_new.php index 38c95577..dfe9749f 100644 --- a/system/pages/account/register_new.php +++ b/system/pages/account/register_new.php @@ -40,7 +40,7 @@ else $message = '
Your recovery key were send on email address '.$account_logged->getEMail().' for '.$config['generate_new_reckey_price'].' premium points.'; } else - $message = '

An error occorred while sending email ( '.$account_logged->getEMail().' ) with recovery key! Recovery key not changed. Try again. Error:
' . $mailer->ErrorInfo . '

'; + $message = '

An error occorred while sending email ( '.$account_logged->getEMail().' ) with recovery key! Recovery key not changed. Try again later. For Admin: More info can be found in system/logs/mailer-error.log

'; $twig->display('success.html.twig', array( 'title' => 'Account Registered', diff --git a/system/pages/admin/mailer.php b/system/pages/admin/mailer.php index 48edfcd6..7ec6cc0d 100644 --- a/system/pages/admin/mailer.php +++ b/system/pages/admin/mailer.php @@ -30,7 +30,7 @@ if ($preview) { $preview_done = _mail($account_logged->getCustomField('email'), $mail_subject, $mail_content); if (!$preview_done) - error('Error while sending preview mail: ' . $mailer->ErrorInfo); + error('Error while sending preview mail. More info can be found in system/logs/mailer-error.log'); } } @@ -60,7 +60,7 @@ foreach ($query as $email) { else { $failed++; echo '
'; - error('An error occorred while sending email to ' . $email['email'] . '. Error: ' . $mailer->ErrorInfo); + error('An error occorred while sending email to ' . $email['email'] . '. For Admin: More info can be found in system/logs/mailer-error.log'); } } diff --git a/system/pages/createaccount.php b/system/pages/createaccount.php index 0b94a2cc..8af31629 100644 --- a/system/pages/createaccount.php +++ b/system/pages/createaccount.php @@ -217,8 +217,7 @@ if($save) } else { - error('An error occorred while sending email! Account not created. Try again. Error:
' . $mailer->ErrorInfo . '
More info in system/logs/error.log'); - log_append('error.log', '[createaccount.php] An error occorred while sending email: ' . $mailer->ErrorInfo . '. Error: ' . print_r(error_get_last(), true)); + error('An error occorred while sending email! Account not created. Try again. For Admin: More info can be found in system/logs/mailer-error.log'); $new_account->delete(); } } @@ -263,8 +262,7 @@ if($save) if(_mail($email, 'Your account on ' . $config['lua']['serverName'], $mailBody)) echo '
These informations were send on email address ' . $email . '.'; else { - error('An error occorred while sending email (' . $email . ')! Error:
' . $mailer->ErrorInfo . '
More info in system/logs/error.log'); - log_append('error.log', '[createaccount.php] An error occorred while sending email: ' . $mailer->ErrorInfo . '. Error: ' . print_r(error_get_last(), true)); + error('An error occurred while sending email. For Admin: More info can be found in system/logs/mailer-error.log'); } } diff --git a/system/pages/lostaccount.php b/system/pages/lostaccount.php index bb0ac4cc..95c179ac 100644 --- a/system/pages/lostaccount.php +++ b/system/pages/lostaccount.php @@ -111,7 +111,7 @@ elseif($action == 'sendcode') else { $account->setCustomField('email_next', (time() + 60)); - echo '

An error occorred while sending email! Try again or contact with admin. Error:
' . $mailer->ErrorInfo . '

'; + echo '

An error occorred while sending email! Try again later or contact with admin. For Admin: More info can be found in system/logs/mailer-error.log

'; } } else @@ -330,7 +330,7 @@ elseif($action == 'step3') } else { - echo '

An error occorred while sending email! You will not receive e-mail with this informations. Error:
' . $mailer->ErrorInfo . '

'; + echo '

An error occorred while sending email! You will not receive e-mail with this informations. For Admin: More info can be found in system/logs/mailer-error.log

'; } } else @@ -513,7 +513,7 @@ elseif($action == 'setnewpassword') } else { - echo '

New password work! An error occorred while sending email! You will not receive e-mail with new password. Error:
' . $mailer->ErrorInfo . '

'; + echo '

New password work! An error occorred while sending email! You will not receive e-mail with new password. For Admin: More info can be found in system/logs/mailer-error.log; } echo '