i want to send an email with attachment using wordpress' wp_mail function.
With this function it works fine to send emails but the attachment isn't there when i check my email.
function dd_send_email(){
$dd_path = $_POST['upload_image'];
// echo $dd_path;
$email_sent = false;
// get email template data
$email_template_object = dd_get_current_options();
// if email template data was found
if ( !empty( $email_template_object ) ):
// setup wp_mail headers
$wp_mail_headers = array('Content-Type: text/html; charset=UTF-8');
$mail_attachment = $dd_path;
// use up_mail to send email
$email_sent = wp_mail( array( 'example@mail.no') , $email_template_object['dd_emne_forhaandsbestilling'], $email_template_object['dd_email_text_forhaandsbestilling'], $wp_mail_headers, $mail_attachment );
endif;
return $email_sent;
}
The variable $dd_path
(something like: http://localhost/norskeanalyser/wp-content/uploads/Testanalyse-2.pdf) contains the path of the file which i do upload from the media uploader in another function.
Thanks for your help!