Answer the question
In order to leave comments, you need to log in
How to programmatically send an email with an attachment, Drupal?
I do it by analogy xandeadx.ru/blog/drupal/539 , modules are installed.
My task is simpler - I want to attach a file from the site root README.txt
$attachment = array(
'filepath' => 'README.txt'
);
drupal_mail('system', 'mail', '[email protected]', language_default(), array(
'context' => array(
'subject' => 'Some subject',
'message' => 'Some message',
'attachment' => $attachment
)
));
Answer the question
In order to leave comments, you need to log in
1. Not 'attachment' but 'attachments'
2. An array of files must be passed to 'attachments', not a filepath
3. 'attachments' must be in params, not 'context'
$attachment = array(
'filepath' => 'README.txt'
);
drupal_mail('system', 'mail', '[email protected]', language_default(), array(
'context' => array(
'subject' => 'Some subject',
'message' => 'Some message',
),
'attachments' => array($attachment),
));
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question