首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WP_MAIL()不向Gmail发送附件

WP_MAIL()不向Gmail发送附件
EN

Stack Overflow用户
提问于 2022-10-25 03:22:50
回答 1查看 39关注 0票数 0

我试图使用WordPress wp_mail功能向Gmail(ahmedkaizur@gmail.com)发送带有附件的邮件。也试过另一个Gmail。我不会在邮箱里收到电子邮件。$runner = wp_mail( $receiver, $subject, $msg, $headers, $attachment );

但是,当我在没有附件的情况下发送邮件时,就会收到邮件。$runner = wp_mail( $receiver, $subject, $msg );

但是,如果我发送带有/没有附件的邮件,请将邮件发送到另一封电子邮件(kaizur@crebsol.com)。

注意:虽然 kaizur@crebsol.com是一个网络邮件,但它是与gmail链接的。

提前谢谢。

这是我的密码。

代码语言:javascript
运行
复制
$attachment = array(WP_CONTENT_DIR . '/uploads/reunion_pdf/reunion_reg_'.$user_id.'.pdf');      

//$headers = 'From: ' . get_bloginfo( 'name' ) . ' <' . get_bloginfo( 'admin_email' ) . '>' . "\r\n\\";

$headers = array();
$headers[] = 'Content-Type: text/html; charset=UTF-8';
$headers[] = 'From: '.get_option( 'blogname' ).' <'.get_option( 'admin_email' ).'>';

// $headers[] = 'MIME-Version: 1.0' . "\r\n";
// $headers[] = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// $headers[] = 'From: '.get_option( 'blogname' ).' <'.get_option( 'admin_email' ).'>';

$subject = sprintf( __( '[%s] Payment Received', 'wp-user-frontend' ), get_bloginfo( 'name' ) );

$msg = sprintf( __( 'New payment received at %s.', 'wp-user-frontend' ), get_bloginfo( 'name' ) );
$msg .= ' You recieved ৳'.$amount.' for Reunion 2023 from '.$user_name.'('.$user_email.') (User ID : '.$user_id.').';
        
//$adminmail = get_option('admin_email');
//$adminmail = 'kaizur@crebsol.com';
$adminmail = 'ahmedkaizur@gmail.com';       
$receiver = array($adminmail);
$runner = wp_mail( $receiver, $subject, $msg, $headers, $attachment );
EN

回答 1

Stack Overflow用户

发布于 2022-10-25 16:33:19

最后,我找到了解决办法。我想归功于Vel

谢谢他的宝贵意见。我修改了他的密码。我将$headers = array(); $headers[] = 'Content-Type: text/html; charset=UTF-8'; $headers[] = 'From: '.get_option( 'blogname' ).' <'.get_option( 'admin_email' ).'>';替换为

$headers[]= "Content-Transfer-Encoding: 7bit". PHP_EOL;

而且工作也很好。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74188809

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档