I have a site working on drupal 6 , and i uses drupal's default email function drupal_mail() to send emails , but unfortunately its not sending email and gives me "email not send , please contact site administrator" error , is there any smtp settings i need to include ?

When i tried like follows :

$to = "[email protected]"; // to e-mail address
$from = "[email protected]"; // from e-mail address
$subject = "text to display in e-mail subject"; // subject of e-mail
$body = "text to display in e-mail body"; 
//params is the array passed to hook_mail function 
$params = array(
    'subject' => $subject,
    'body' => $body,

if(drupal_mail('test', 'information', $to, language_default(), $params, $from)){
     echo "mail send successfully";

it gives me mail send successfully message but mail is not delivered .

  • 1
    Ask server administrators if php mail function works. My guess is it isn't enabled on your hosting. Exact reason can't be known without access to logs, search your server's error log for entries with mail in it. Or again - ask your hosting company.
    – Mołot
    Jul 12, 2015 at 16:12

1 Answer 1


Next to drupal_mail you also need https://api.drupal.org/api/drupal/developer%21hooks%21core.php/function/hook_mail/6 to send the mails.

This hooks tells Drupal what to do with 'params'. $params['body'] does not automaticaly becomes the body.

From the example module:

function email_example_mail($key, &$message, $params) {
  global $user;

  // Each message is associated with a language, which may or may not be the
  // current user's selected language, depending on the type of e-mail being
  // sent. This $language variable is used later in the t() calls for subject
  // and body to ensure the proper translation takes effect.
  $language = $message['language'];

  switch ($key) {
    // Send a simple message from the contact form.
    case 'contact_message':
      $message['subject'] = t('E-mail sent from @site-name', array('@site-name' => variable_get('site_name', 'Drupal')), $language->language);
      // Note that the message body is an array, not a string.
      $message['body'][] = t('@name sent you the following message:', array('@name' => $user->name), $language->language);
      // Because this is just user-entered text, we do not need to translate it.
      $message['body'][] = $params['message'];

Take extra notice the body is an array! Edit: some clarification: The subject of the message is a string, like you would expect. So you can fill the subject line like this:

$message['subject'] = 'Any string, with '. $param['subject'] .  ' or not.';

The body however is not a string, and can not be filled this way. It's an array of strings. The very least you need one part. e.g.:

$message['body'][] = $params['body'];

In the end, Drupal wil implode the array to one big string.

Putting the body in parts allows for other modules to use hook_mail_alter, to change only parts of the e-mail, e.g. only the heading of the message.

/end edit

However, without this hook your mail should have been sent. But it is very likely it was blocked by a spam filter (empty body and empty subject from, probably, an unauthorized source).

  • 1
    OP is not asking "how to send email in Drupal", but "what steps Drupal follows to send my email". What you posted is true, but it is not an answer to the question as asked.
    – Mołot
    Jul 12, 2015 at 19:33
  • I've been in a similar situation in the past. The system at some level blocked the email from being sent because of SPAM rules. Putting in the second part, fixed my issue. Jul 12, 2015 at 19:40
  • can you please clarify "body is an array" part, because i dont know how to integrate this ?
    – KTM
    Jul 13, 2015 at 8:38
  • I've edited the answer with some clarification, I hope this helps! Jul 13, 2015 at 18:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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