问题
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