This is a problem that I am getting with the latest version of Optional Mail (1.1) and Drupal 7.28 .

When user completes the registration, or when I unblock the user, there is always a warning:

Unable to send e-mail. Contact the site administrator if the problem persists!

Please tell, how do I get rid of this warning? Its very annoying

Comments

sharky365’s picture

Quick and dirty fix if you dont need email at all:

1) open ./forum/includes/mail.inc file
2) go to drupal_mail() function (line 122)
3) to disable the mail function, you need to comment a large part of it.
put in /* */ everything below $message = array ( ... ) ;
until return $message;

This will break the e-mail function of Drupal website, but there will be no displayed warnings anymore

There is also a more elegant solution, when you search through all the Drupal files for "drupal_mail()" function:

cd ./forum
find . -type f | xargs grep -l "drupal_mail()"

and then comment the drupal_mail() function where you dont need it

selfsimilar’s picture

Add the following to the end of optional_mail_on_register.module. This will block sending any mail to an account without an e-mail address.

<?php
/**
 * Implements hook_mail_alter().
 */
function optional_mail_on_register_mail_alter(&$message) {
  // Only send mail if recipient has e-mail address
  if (isset($message['params']['account']) && empty($message['params']['account']->mail)) {
    $message['send'] = FALSE;
  }
}
?>
jumpthattb’s picture

Thanks Selfsimilar! Works like a charm!