Skip to content

Commit

Permalink
- Patch #169627 by JirkaRybka: improved logging of mail problems.
Browse files Browse the repository at this point in the history
  • Loading branch information
dbuytaert committed Aug 26, 2007
1 parent 5e73b66 commit 7531f95
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
10 changes: 9 additions & 1 deletion includes/mail.inc
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@
* @return
* The $message array structure containing all details of the
* message. If already sent ($send = TRUE), then the 'result' element
* will contain the success indicator of the e-mail.
* will contain the success indicator of the e-mail, failure being already
* written to the watchdog. (Success means nothing more than the message being
* accepted at php-level, which still doesn't guarantee it to be delivered.)
*/
function drupal_mail($module, $key, $to, $language, $params = array(), $from = NULL, $send = TRUE) {
$default_from = variable_get('site_mail', ini_get('sendmail_from'));
Expand Down Expand Up @@ -126,6 +128,12 @@ function drupal_mail($module, $key, $to, $language, $params = array(), $from = N
// Optionally send e-mail.
if ($send) {
$message['result'] = drupal_mail_send($message);

// Log errors
if (!$message['result']) {
watchdog('mail', 'Error sending e-mail (from %from to %to).', array('%from' => $message['from'], '%to' => $message['to']), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send e-mail. Please contact the site admin, if the problem persists.'), 'error');
}
}

return $message;
Expand Down
13 changes: 4 additions & 9 deletions modules/user/user.module
Original file line number Diff line number Diff line change
Expand Up @@ -1331,15 +1331,10 @@ function user_pass_submit($form, &$form_state) {

$account = $form_state['values']['account'];
// Mail one time login URL and instructions using current language.
$mail_success = _user_mail_notify('password_reset', $account, $language);
if ($mail_success) {
watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
drupal_set_message(t('Further instructions have been sent to your e-mail address.'));
}
else {
watchdog('user', 'Error mailing password reset instructions to %name at %email.', array('%name' => $account->name, '%email' => $account->mail), WATCHDOG_ERROR);
drupal_set_message(t('Unable to send mail. Please contact the site admin.'));
}
_user_mail_notify('password_reset', $account, $language);
watchdog('user', 'Password reset instructions mailed to %name at %email.', array('%name' => $account->name, '%email' => $account->mail));
drupal_set_message(t('Further instructions have been sent to your e-mail address.'));

$form_state['redirect'] = 'user';
return;
}
Expand Down

0 comments on commit 7531f95

Please sign in to comment.