0

How can I customize drupal_mail() error messages? I 've switched off the display of error messages, but this config does not seem to affect to the management of email messages, which insists on displaying the status of the delivery in the navigator screen.

2

drupal_mail() uses drupal_set_message() to push error messages on mail failure. The only way to suppress those messages is by altering drupal_set_message() output. Depending on the how/why, there's a couple of tacts to take.

One way to do this is a blanket suppression via the Disable Messages module that lets suppress messages based on a few different criteria.

Gives a site owner options to disable specific messages shown to end users. The core drupal message system as offered by drupal_set_message is an excellent way for modules to send out messages to the end users. However not all drupal site owners are keen to show all the messages sent out by drupal core and all modules to their users. This module gives site administrators a reasonably powerful way to filter out messages shown to the end users.

Another, more surgical way, is to manipulate the $_SESSION['messages'] variable which contains the array of pending messages to render, following the execution of drupal_mail().

  • I guess I can make a direct hook to drupal_set_message instead of using this module? It is just for this only purpose, so I don't want to over-saturate the site with more and more modules, espcially if they are doing a single task which may be integrated into my own module. – Cesar Oct 5 '15 at 17:20
  • That was the other tact that I was going to mention, but I didn't want to make the post too long. There's no message hook, but you can manipulate the $_SESSION['messages'] array following drupal_mail() failure. – Shawn Conn Oct 5 '15 at 17:27
  • Thank you very much. However, it still shows an unwanted message. I think it is due to PHPMailer module. I will try to hook this also. Thanks!! – Cesar Oct 6 '15 at 6:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.