我试图使用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链接的。
提前谢谢。
这是我的密码。
$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 );
发布于 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;
而且工作也很好。
https://stackoverflow.com/questions/74188809
复制相似问题