English 中文(简体)
寄送电子邮件时
原标题:Sending email in while loop
  • 时间:2009-11-12 12:56:08
  •  标签:
  • php
  • sendmail

当我试图从与PHPmailer同时发送电子邮件时,有时会向每个接收者发送2份,有时发送3份同一电子邮件(如随机发送)。

这里是我的法典。 你们是否认为存在问题?

 $list = $_POST[ list ];
    $items = rtrim($_POST[ items ],",");
    $query = "SELECT * FROM `mail` WHERE `ID` IN ($items)";
    $result = mysql_query($query);
    $from = "donotreply@mysite.net";
    $fromname = "mysite";

    $mail = new PHPMailer(true); 

    $mail->IsSendmail(); 

    $mail->From       = $from;
    $mail->FromName   = $fromname;

    $mail->Subject  = "Your subscription was confirmed";

while ($row = mysql_fetch_array ($result))
{
    // HTML body
    $body .= "<p>Hi ". $row[ name ] ." <br /><br />";
    $body .= "Your subscription request to " . $l_name ." s list was confirmed.<br /><br />";
    $body .= "Thank You !<br /><br />";

    // Plain text body (for mail clients that cannot read HTML)
    $text_body  = "To view the message, please use an HTML compatible email viewer!";

    $mail->Body    = $body;
    $mail->AltBody = $text_body;
    $mail->AddAddress($row[ email ]);


    $mail->Send();
    $mail->ClearAddresses();

}

您是否认为应该把“mail->send();从左边排出,从一个阵列取所有电子邮件?

或者,你是否认为是MySQL问题的问题?

Edit:我对数据库进行了检查,但对数据库没有任何问题,但我发现,(邮袋中有2个邮件)它通常发送第一份电子邮件,但第二次发送的是被篡改的单人变量,即发送了被篡改的单人变量。

FIX:hey,我做了,我刚刚添加了$ person = “”;,现在它运作完美!

问题回答

我认为数据库中重复数据的可能性更大。

另外,还有一股担心名册上缺乏验证(或根本没有验证)。

不妨回顾:

cleaning (美元)

最新消息:虽然你可以先使用DISTINCT来回答问题,但首先会质疑复制件是如何去的,并视之为恰当问题。

关于你的询问,仅贴上“SlectT DISTINCT”,你不再看到贵国数据库存在问题。

您提到在你提问结束时的定点,但这里是造成这种影响的原因:

<代码>= 运营商对现值的估价,而 超出其价值。 在第二版(<代码> > 原文)的首期末,你在第二版中附上了电子邮件,然后附上了现值。 每当休息时,请在电子邮件结束前再加一本。 如你所说,设置<代码> 任何人 = “ ”,以取代电子邮件的机体。

另一种确定方式是将第1项转让(=)而不是.=:

while ($row = mysql_fetch_array ($result))
{
  // HTML body
  $body = "<p>Hi ". $row[ name ] ." <br /><br />"; // This line only has  = 
  $body .= "Your subscription request to " . $l_name ." s list was confirmed.<br /><br />";
  $body .= "Thank You !<br /><br />";

  // etc...
}




相关问题
Brute-force/DoS prevention in PHP [closed]

I am trying to write a script to prevent brute-force login attempts in a website I m building. The logic goes something like this: User sends login information. Check if username and password is ...

please can anyone check this while loop and if condition

<?php $con=mysql_connect("localhost","mts","mts"); if(!con) { die( unable to connect . mysql_error()); } mysql_select_db("mts",$con); /* date_default_timezone_set ("Asia/Calcutta"); $date = ...

定值美元

如何确认来自正确来源的数字。

Generating a drop down list of timezones with PHP

Most sites need some way to show the dates on the site in the users preferred timezone. Below are two lists that I found and then one method using the built in PHP DateTime class in PHP 5. I need ...

Text as watermarking in PHP

I want to create text as a watermark for an image. the water mark should have the following properties front: Impact color: white opacity: 31% Font style: regular, bold Bevel and Emboss size: 30 ...

How does php cast boolean variables?

How does php cast boolean variables? I was trying to save a boolean value to an array: $result["Users"]["is_login"] = true; but when I use debug the is_login value is blank. and when I do ...

热门标签