Example usage of drupal_mail_send()
Just wanted to put this up as a quick example for future usage.
$headers = array(
'MIME-Version' => '1.0',
'Content-Type' => 'text/plain; charset=UTF-8; format=flowed; delsp=yes',
'Content-Transfer-Encoding' => '8Bit',
'X-Mailer' => 'Drupal',
);
drupal_mail_send($message = array(
'id' => 'test_test',
'from' => 'test@gmail.com',
'to' => 'test@gmail.com',
'subject' => 'test',
'body' => 'test2',
'headers' => $headers,
));
Comments
Adam Behnke
Fri, 09/30/2011 - 07:11
The submitted from address () is not valid.
On your implementation of Drupal, you may get this error with the above code: The submitted from address () is not valid.
To fix it, simply add a 'from' variable in the associative array, such as:
drupal_mail_send($message = array(
'id' => 'test_test',
'from' => $FROM_EMAIL,
'to' => $to,
'subject' => $SUBJECT,
'body' => $body,
'headers' => array(
'MIME-Version' => '1.0',
'Content-type' => 'text/html; charset=iso-8859-1',
),
));
Drupal Caulfield
Wed, 11/09/2011 - 14:47
Excellent, thanks for this. I
Excellent, thanks for this. I updated the post to reflect your suggestion.
Anonymous
Tue, 10/11/2011 - 05:20
how to send to multiple users...
How can we send emails to multiple users by using this function.. There doesnt seems to be any cc or bcc option available in this function.. Please help..
Sanjeet
Mon, 11/14/2011 - 09:23
Good Idea
Excellent, thanks for this. I updated the post to reflect your suggestion.
Add new comment