[support] Within a custom module I am trying to send so that an email is sent but I get the error The submitted from address () is not valid.

Earnie Boyd earnie at users.sourceforge.net
Thu Mar 31 12:27:25 UTC 2011


John Mitchell wrote:
> Also I forgot to mention below that this is on drupal 6.
> 
> On Thu, Mar 31, 2011 at 6:44 AM, John Mitchell <mitchelljj98 at gmail.com>wrote:
> 
>> Within a custom module I am trying to send the below so that an email is
>> sent but I get the error *The submitted from address () is not valid.*
>> This *from *email address does exist so why is it giving me this error?
>>

You're missing the 'from' element in the message.  But you shouldn't be
using drupal_mail_send directly.  You should use drupal_mail[1] and
implement hook_mail[2] to add your subject and body to the message array.

>> $message = array(
     'from' => 'support at domain123.com',
>>   'to' => 'username1 at domain123.com',
>>   'subject' => t('Example subject'),
>>   'body' => t('Example body'),
>>   'headers' => array('From' => 'support at domain123.com'),
>> );
>> drupal_mail_send($message);

[1]
http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/6
[2]
http://api.drupal.org/api/drupal/developer--hooks--core.php/function/hook_mail/6

-- 
Earnie
-- http://progw.com
-- http://www.for-my-kids.com


More information about the support mailing list