You are here

function _mass_contact_send_message in Mass Contact 6

Same name and namespace in other branches
  1. 7 mass_contact.module \_mass_contact_send_message()

Sends the message.

Parameters

string $message_key: A key to identify the email sent.

string $to: To whom the message will be delivered.

array $params: The message array.

string $from_email: The message sender's email address.

string $success_message: The message that will be displayed to the user, if sending is successful.

Return value

boolean The result of the call to drupal_mail(): 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 email, 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.)

2 calls to _mass_contact_send_message()
mass_contact_mail_page_submit in ./mass_contact.module
Processes the main Mass Contact mail form.
_mass_contact_prepare_message_for_sending in ./mass_contact.module
This is for preparing a message that has been queued for sending.

File

./mass_contact.module, line 370
This is the main code file for the Mass Contact module. This module enables users to contact multiple users through selected roles.

Code

function _mass_contact_send_message($message_key, $to, &$params, $from_email, $success_message) {

  // This call was changed from drupal_mail() due to this bug report:
  // http://drupal.org/node/473838
  if (variable_get('smtp_library', '') && file_exists(variable_get('smtp_library', ''))) {
    $success = drupal_mail('mass_contact', $message_key, $to, language_default(), $params, $from_email);
  }
  else {
    $success = _mass_contact_mail('mass_contact', $message_key, $to, language_default(), $params, $from_email);
  }

  // Capture the rate limiting information.
  $recipient_limit = variable_get('mass_contact_recipient_limit', 0);
  $wait_time = variable_get('mass_contact_wait_time', 0);
  if ($success['result']) {
    if (empty($recipient_limit) && empty($wait_time)) {
      drupal_set_message(t($success_message));
    }
    else {
      watchdog('mass_contact', $success_message);
    }
  }
  return $success['result'];
}