currently I am trying to write a plugin. Within that plugin I want to send an email with a picture as attachment to one specified email address. I know I can send emails with wp_mail, but I don’t know how to include the attachment there.
Does WordPress provide a function to send emails with attachments or do I have to consider other libraries for doing that?
Confused by the Codex-Page(http://codex.ww.wp.xz.cn/Function_Reference/wp_mail), where the usage did not mention attachments at all, I thought it is not possible. But a look into the file pluggable.php offered me the whole usage of wp_mail. So it is possible with just: <?php wp_mail($to, $subject, $message, $headers = '', $attachments = array() ); ?>
Hi All,
We can use wp_mail function send emails with attachments
<?php
move_uploaded_file($_FILES[“attachment”][“tmp_name”],WP_CONTENT_DIR .’/uploads/’.basename($_FILES[‘attachment’][‘name’]));
$attachments = array(WP_CONTENT_DIR .”/uploads/”.$_FILES[“attachment”][“name”]);
wp_mail($to, $subject, $message, $headers, $attachments);
?>
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘wp_mail with attachment’ is closed to new replies.