繁体   English   中英

我无法在wp_mail函数中发送附件文件

[英]I can't send attchment file in wp_mail function

我尝试使用wp_mail函数发送带有附件的邮件,但该邮件无法成功发送附件,因此请帮我。
我的代码如下。

$filename = wp_get_attachment_metadata($attchment_id);//Here media file attchment id
       $to = get_user_meta($result->user_id,'billing_email',true);//email id
       $subject = $result->msg_title;//Subject
       $message = $result->msg_body;//HTML message text
       $attachments = array(WP_CONTENT_DIR.'/'.$filename['file'] );//I also try with ABSPATH
       $headers[] = 'Content-Type: text/html; charset=UTF-8';
       $headers[] = 'From: Wordpress ' . "\r\n";
       $sendmail = wp_mail($to, $subject, $message,$headers,$attachments);

以下代码可以帮助您,

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

有关更多信息,请参见http://codex.wordpress.org/Function_Reference/wp_mail

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM