How to send an email with attachment in wordpress?

邮差的信 提交于 2021-02-07 13:43:59

问题


Now I can send an email without attachment :

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

But how can I send an email with attachment?


回答1:


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

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




回答2:


Refer below e.g.

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



回答3:


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;
}



回答4:


I wrote a plugin to send to emails with attachments from WP.

Quick Mail sends text or HTML emails with attachments from the dashboard. HTML emails can include shortcodes.

Get Quick Mail from WordPress or Github.



来源:https://stackoverflow.com/questions/4554664/how-to-send-an-email-with-attachment-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!