You are here

function invite_by_email_send_invitation in Invite 7.4

Implements sending_controller_send_invitation function.

The invitation email is sent to the invitee.

Parameters

object $invite: Invite object.

Return value

bool TRUE, if sending was successful; FALSE otherwise.

1 call to invite_by_email_send_invitation()
invite_by_email_invite_send in modules/invite_by_email/invite_by_email.module
Invite Send.

File

modules/invite_by_email/invite_by_email.module, line 239
Main file for Invite by e-mail.

Code

function invite_by_email_send_invitation($invite) {
  global $language;

  // Check if this is an existing invite.
  $existing_invite = invite_load($invite->iid);
  if ($existing_invite) {
    $invite->expiry = REQUEST_TIME + variable_get('invite_default_expiry_time', 30) * 60 * 60 * 24;
  }
  $entity = entity_metadata_wrapper('invite', $invite);
  if (!variable_get('invite_use_users_email', 0)) {
    $from = variable_get('invite_manual_from', '');
  }
  else {
    $from = $entity->inviter->mail
      ->value();
  }
  if (empty($from)) {

    // Never pass an empty string to drupal_mail()
    $from = NULL;
  }
  $params = array(
    'invite' => $invite->iid,
  );

  // Override Reply-To address.
  if (!variable_get('invite_use_users_email_replyto', 0)) {
    $reply_to = variable_get('invite_manual_reply_to', '');
  }
  else {
    $reply_to = $entity->inviter->mail
      ->value();
  }
  if (!empty($reply_to)) {
    $params['reply-to'] = $reply_to;
  }

  // Send e-mail.
  $result = drupal_mail('invite_by_email', 'invite', $entity->field_invitation_email_address
    ->value(), $language, $params, $from, TRUE);
  return $result['result'];
}