0

Need help ASAP. My function is sending e-mail on successful quit. E-mail is sent well. The problem is that i'm always getting "Invalid address:" before my normal exit message. Code is following:

$message_text = array(
'id' => 'modulename' . '_' . 'key',
'to' => '2@example.com',
'subject' => "OK",
'body' => array("OK"),
'headers' => array(
    'From' => '1@example.com',
    'Sender' => '1@example.com',
    'Return-Path' => '1@example.com',
          ),
);
$system = drupal_mail_system($module, $key);
$message = $system->format($message_text);
$system->mail($message);

Thanks.

1
  • Well. Not the best solution. I know, but currently I managed to avoid this by cleaning output buffer with ob_clean(); – swindler Nov 19 '12 at 12:27
1

This is because of the absence of $message_text['from']; In SMTP module smtp.module.inc line 74-85 there is hack that handles the absence of 'Reply-To' by setting it to $message['from'] which is also absent, consequently 'Reply-To' will be empty hence throwing the error Invalid address:. add $message_text['from'] = 'your from address' this will solve the issue.

0

Try at last

$system = drupal_mail_system($module, $key);
if ($system->mail($message)) {
  // Success.
}
else {
  // Failure.
}

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.