wp_mail附件不起作用

时间:2015-09-24 06:32:07

标签: php wordpress attachment

我尝试将wp_mail与附件一起使用,但我无法收到任何附件。请帮忙

$attachments = get_user_meta($userID, 'resume_pdf', true);

if ($attachments != '') {
  wp_mail($to,$subject,$msg,$headers,$attachments);
  $msg .= '<br><br>' . $attachments;
} else{
  wp_mail($to,$subject,$msg,$headers);
}

保存为resume_pdf的是这样的: http://aiprojectlink.com/wp-content/uploads/userpro/1/560387d6eaa3b.pdf

我认为它应该是完整的路径,我可以通过点击直接打开链接,但没有附件。 请帮忙,谢谢。

1 个答案:

答案 0 :(得分:0)

请参阅examples中的wp_mail

$attachments应为路径路径数组。不是网址。

Codex的例子:

$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 );
相关问题