我用wp-mail发送图像。问题是它没有附加图像!
下面是$attachment_img字符串:https://example.com/wp-content/uploads/2021/10/example.jpg,所以路径是正确的
以下是功能:
function send_mail_to_admin($orderId , $attachment_img){
$headers = array('Content-Type: text/html; charset=UTF-8','From: انجمن آبزیان ');
$body = "
یک مشتری سفارش با شماره $orderId ثبت کرد
";
wp_mail( "nabestan98@gmail.com", "دریافت نامه کاربر", $body, $headers , array($attachment_img) );
}发布于 2021-10-08 10:39:43
我把代码改到这个了,它起作用了!不知道我为什么要这么做,这很奇怪,但无论如何。
function send_mail_to_admin($orderId , $attachment_img){
$attachment_img = str_replace("https://seabou.com/wp-content" , "" , $attachment_img);
$attachment_img = array( WP_CONTENT_DIR . $attachment_img );
$headers = array('Content-Type: text/html; charset=UTF-8','From: انجمن آبزیان ');
$body = "
یک مشتری سفارش با شماره $orderId ثبت کرد
";
wp_mail( "nabestan98@gmail.com", "دریافت نامه کاربر", $body, $headers , $attachment_img );
}https://wordpress.stackexchange.com/questions/396634
复制相似问题