dongyou7292 2018-07-18 20:44
浏览 14

php mail function error - 我的客户列表的最后一个电子邮件地址将显示在收件箱中

I am working to get more personalised with my clients by mail. Everything works fine with the code but when i do some test mails, Only the last email address of my client list will be displayed in the inbox.

E.g. My client mailing list is 100+ email addresses and when I mail them, all of them will see the mail address on the last line in my mailing list instead of theirs.

See <p>Dear '.$clientmail.', </p>

and

$address = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
foreach ($address as $clientmail) {
    $mail_sent = @mail($clientmail);
}

I'm working to fix this problem for a good few hours, but can't.. If someone can fix this that would be highly appreciated.

Here is full code to give you more insight.

<?php
// Turn off output buffering
ini_set('output_buffering', 'on');
// Turn off PHP output compression
ini_set('zlib.output_compression', false);

//Flush (send) the output buffer and turn off output buffering
//ob_end_flush();
while (@ob_end_flush());

// Implicitly flush the buffer(s)
ini_set('implicit_flush', true);
ob_implicit_flush(true);

flush();

/// Now start the program output

$subject = 'subject here';
$headers = "From: mail <mail @mail.com>
" . 
         "Reply-To: mail <mail @mail.com>
" . 
         "MIME-Version: 1.0
" . "Content-Type: text/html; charset=iso-8859-1";

$address = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
foreach ($address as $clientmail) {
    $mail_sent = @mail($clientmail);
}

$template = file_get_contents("template/template.png");

$message = '
<html>
<head>
<title></title>
</head>
<body>
    <p>Dear '.$clientmail.', </p>
    <strong>rest of content</strong>
    <p>'.$template.'</p>
</body>
</html>
'; 

$emails = file('MUgWgJJE9m7FHh4TFrLHf6YzE.txt', FILE_IGNORE_NEW_LINES);
$x = 1;
foreach ($emails as $email) {
    $mail_sent = @mail($email, $subject, $message, $headers, '-f mail@mail.com');
    echo $mail_sent ? 
    $x . '. Mail send to: ' . $email . ' | ' . '<b><font color=green> Successfully Sended!</font><font color=lime> &check; </font></b>' . '<br/>' : 
    $x . '. Mail send to: ' . $email . ' | ' . '<b><font color=red> Error 02931: Contact To Fix Issue</font></b>' . '<br/>'; 
    $x++;

}

ob_end_flush();
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
    • ¥20 软件测试决策法疑问求解答
    • ¥15 win11 23H2删除推荐的项目,支持注册表等
    • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
    • ¥15 qt6.6.3 基于百度云的语音识别 不会改
    • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
    • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
    • ¥15 lingo18勾选global solver求解使用的算法
    • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
    • ¥20 测距传感器数据手册i2c