php发送了多封电子邮件

发布于 2025-01-21 07:54:23 字数 2400 浏览 1 评论 0原文

我正在使用PHPP发送Eamils,并且我收到了多个重复的电子邮件发送到电子邮件帐户,这是我正在使用的代码。

<?php 
//start mail out
    
set_time_limit(0); // this will keep the script from stopping if it takes longer then 30 seconds, must have this here
$emailaddress = array('[email protected]', '[email protected]', '[email protected]');
$emailsubject = "New messages added to the nerjabible website";
//$emailbody = file_get_contents(".email_out.html");
$fromaddress = "[email protected]";
$i = count($emailaddress);
$z = 0;
     
// here we check how many email address's we have, if its is 0, then we don't start the email function
if ($i != 0)
{// start if
     
    // Lets loop until we reach the count from email address array
    while ($i != $z)
    {// start while
    
        // here we send the email to the varables from above, using the email array incrament
        if (mail($emailaddress[$z], $subject, $message, $headers))
            // mail($emailaddress[$z], $emailsubject, $message, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
            // lets echo out that the email was sent
            echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
     
        // increment the array one, so we get a new email address from the array
        ++$z;
    
    }// end while 
     
}//end if
     
else
{//start else
    
    // we echo out that no emails where found in the array and end the script
    echo "Warning: No emails in array.";
     
}// end else
echo "finished mails sent";
//end mail out
    
?> 

我已经尝试了此代码,没有任何其他代码,甚至还发送了我

if (mail($to, $subject, $message, $headers))
{ 
    $answer = "Messages accepted";
}
else
{
    $answer = "Error: Messages not accepted";
}

也尝试将其发送到我的主机帐户和各种Gmail帐户,我尝试将代码包装为for循环,无济于事,我仍然获取3-6个重复电子邮件到任何帐户。

I am using phpp to send eamils and I am getting multiple duplicate emails being sent to the email account, Here is the code I am using.

<?php 
//start mail out
    
set_time_limit(0); // this will keep the script from stopping if it takes longer then 30 seconds, must have this here
$emailaddress = array('[email protected]', '[email protected]', '[email protected]');
$emailsubject = "New messages added to the nerjabible website";
//$emailbody = file_get_contents(".email_out.html");
$fromaddress = "[email protected]";
$i = count($emailaddress);
$z = 0;
     
// here we check how many email address's we have, if its is 0, then we don't start the email function
if ($i != 0)
{// start if
     
    // Lets loop until we reach the count from email address array
    while ($i != $z)
    {// start while
    
        // here we send the email to the varables from above, using the email array incrament
        if (mail($emailaddress[$z], $subject, $message, $headers))
            // mail($emailaddress[$z], $emailsubject, $message, "From: " .$fromaddress. "\nX-Mailer: PHP 4.x");
            // lets echo out that the email was sent
            echo $z + 1 . " out of " . $i . " emails sent. (" . $emailaddress[$z] . ")<br>";
     
        // increment the array one, so we get a new email address from the array
        ++$z;
    
    }// end while 
     
}//end if
     
else
{//start else
    
    // we echo out that no emails where found in the array and end the script
    echo "Warning: No emails in array.";
     
}// end else
echo "finished mails sent";
//end mail out
    
?> 

I have tried this code on its own without any other code and I have even just sent

if (mail($to, $subject, $message, $headers))
{ 
    $answer = "Messages accepted";
}
else
{
    $answer = "Error: Messages not accepted";
}

I have also tried sending to my host account and various gmail accounts and I have tried wrapping the code in a for loop, all to no avail, I still get 3-6 duplicate emails to any account.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文