Hello,
I am trying to send email with attachment using hook mail.
I am using it in a content type with a file upload field.
When a node is created, I wish that file should be sent to some email address as an attachment.
I am able to send fields content like description or title.
But can send attachment.

$mailto='myemail@mail.com';
$file='FilePathHere';//What to do with this

$params = array(
'file' => $file,
'name' => 'Tanvir Ahmad','content'=> $content);
drupal_mail('MODULNAME', 'triggerkey', $mailto, language_default(), $params);


function MODULNAME_mail($key, &$message, $params) {
  switch ($key) {
    case 'triggerkey':
      // note: data can be passed to this function in the $params array - 
      $message['subject'] = t('EMAIL SUBJECT');
      $message['body'] = $params['file'].$params['name'];
	
	break;   
  }
}

Response is appriciated.
Thnks

Comments

tanvirahmad’s picture

Project: » Email Field
Version: » 6.x-1.2
drupalnesia’s picture