如何在wordpress中发送带附件的电子邮件?

时间:2010-12-29 13:50:08

标签: php wordpress email-attachments

现在我可以发送没有附件的电子邮件:

wp_mail( $to, $subject, $message, $headers);

但是如何发送带附件的电子邮件?

4 个答案:

答案 0 :(得分:8)

 <?php wp_mail( $to, $subject, $message, $headers, $attachments ); ?> 

http://codex.wordpress.org/Function_Reference/wp_mail

答案 1 :(得分:7)

参考下文,例如

$attachments = array(WP_CONTENT_DIR . '/uploads/file_to_attach.zip');
$headers = 'From: My Name <myname@mydomain.com>' . "\r\n";
wp_mail('test@test.com', 'subject', 'message', $headers, $attachments);

答案 2 :(得分:0)

add_filter( 'wpcf7_mail_components', 'mycustom_wpcf7_mail_components' );

function mycustom_wpcf7_mail_components( $components ) {
    $components['attachments'][] = 'full path of your PDF file';

    return $components;
}

答案 3 :(得分:0)

我写了一个插件,用于发送带有WP附件的电子邮件。

Quick Mail会从信息中心发送包含附件的文字或HTML电子邮件。 HTML电子邮件可以包含短代码。

WordPressGithub获取快速邮件。