tags:

views:

8

answers:

1

Hi, I am using drupal6 and i installed the rules module configured it. I need to send email to user with an attachment.. Thanks

A: 

Sending pdf files is just a matter of setting mime type and stuff like that. I have some example code you can look at, for how you could do it.

$trenner  = md5(uniqid(time()));
$params = array();
$params['content_type'] = "multipart/mixed; boundary=$trenner";
$params['subject'] = $subject;
$params['body']  = "\n--$trenner\n";
$params['body'] .= "Content-Type: text/plain; charset=UTF-8; format=flowed;"."\n\n"; // sets the mime type
$params['body'] .= $message . "\n"; // Message goes here
$params['body'] .= "\n\n";
$params['body'] .= "\n\n";

$dir = file_directory_path().'/';
$pdffile = $dir.$pdffile_name;
$pdffile_mime = file_get_mimetype($pdffile);

$params['body']  .= "--$trenner"."\n";
$params['body']  .= "Content-Type:$pdffile_mime; name='$pdffile_name'\n";
$params['body']  .= "Content-Disposition: attachment; filename=$pdffile_name\n";
$params['body']  .= "Content-Transfer-Encoding: base64\n\n";
$params['body']  .= chunk_split(base64_encode($filedata));
$params['body'] .= "--$trenner--";
googletorp

related questions