【问题标题】:How do I send an email with a PDF attachment using rules?如何使用规则发送带有 PDF 附件的电子邮件?
【发布时间】:2010-07-07 06:39:40
【问题描述】:

我正在使用 Drupal 6,我安装了规则模块并对其进行了配置。我需要向我们的用户发送带有附件的电子邮件。

我该怎么做?

【问题讨论】:

    标签: drupal drupal-rules


    【解决方案1】:

    发送 pdf 文件只是设置 mime 类型之类的东西。我有一些示例代码可供您查看,了解您如何 做到这一点。

    $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--";
    

    【讨论】:

      猜你喜欢
      • 2011-10-09
      • 1970-01-01
      • 2013-08-26
      • 2020-11-20
      • 2014-02-28
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 2021-09-14
      相关资源
      最近更新 更多