English 中文(简体)
如何向多个电子邮件地址发送电子邮件?
原标题:How to send email to multiple email addresses?
  • 时间:2012-04-27 03:25:07
  •  标签:
  • php
  • email

我的这种形式正在完美地运作,除非它赢得向多人发送电子邮件。 它只发给一人。 如何确定这一点? 我希望能够向每个人发出个人电子邮件,并寄送电子邮件地址,而不论该电子邮件是否发给其他用户。

最新消息:我用的是打印的电子邮件;如果我只选择一个电子邮件,就会打印,如果超过1份,就会打印任何东西。 因此,这意味着它没有发现超过1个电子邮件。

     $sql = "SELECT email from
    friend_email_ids WHERE my_id= $id ";
    $result = mysql_query($sql);

    $query = mysql_query($sql) or die ("Error: ".mysql_error());

    if ($result == "")
    {
    echo "";
    }
     echo "";


   $rows = mysql_num_rows($result);
   $emails = array();

   if($rows == 0)
   {
   print("");

    }
   elseif($rows > 0)
   {
    while($row = mysql_fetch_array($query))
   {

   array_push($emails, $row[ email ]);


  print("");
  }

  }

$headers = "MIME-Version: 1.0
";
$headers .= "Content-Type: text/html; charset=ISO-8859-1
";
$headers .= "From: $usermail
";
$subject = "$full_name added";
$message = "<html><body>";
$message .= "Hello, <br><br>$full_name posted someth<br><br>";
$message .= "<a href=www.domain.com/signup.php?t=&sign=>Click here.</a><br><br>";
$message .= "</body></html>";
 foreach ($emails as $email) {
mail($email, "Subject: $subject", $message, $headers);
   }


   echo "";
问题回答

您需要使用MySQL sGROUP_CONCAT,将电子邮件合并成mas。 通过在“到”领域填平混合值,它将自动发送给多个接收方:

SELECT GROUP_CONCAT(DISINCT `email` SEPARATOR  , ) from
    friend_email_ids WHERE my_id= $id "
    GROUP BY `email;

专家组 MySQL:

PHP http://www.un.org/Depts/DGACM/index_spanish.htm

rel=“nofollow”>http://php.net/manual/en/Function.mail.php

在公共卫生和社会福利部中,你通常有一些守则,将视而不见。

    mail($to, $subject, $msg, $mailheaders);

您可以设立多个电子邮件接收人,如电子邮件接收人。

    $to  =  [email protected]  .  ,  ; // note the comma
    $to .=  [email protected] ;

com和.将允许多个电子邮件接收人。

两人以上将使用。

    $to  =  [email protected]  .  ,  ;
    $to .=  [email protected]  .  ,  ;
    $to .=  [email protected] ;

To do this automatically, you could set up a foreach with a twist for the last entry in the array

    foreach($email as $to) {
    $lastone = next($email)===FALSE;
    $to .= $email .  ,  ;       
    if(!$lastone){
    $to .= $email;
    }

问题是:

$sql = "SELECT email FROM friend_email_ids WHERE my_id= $id ";

您仅收到一份电子邮件地址,因为只有selecting<>em>,一份电子邮件地址,由用户发送,地址载于$。 为了确定这一点,你必须选择你所需要的所有遗症。 首先,你需要确保有一个称为$ids的变量,储存一份 com子清单。 接着,你问:

$sql = "SELECT email FROM friend_email_ids WHERE my_id IN ($ids)";

如果你的孩子是ger子,就不必像你在最初的询问中那样做。 如果他们有str,那么就确保你在混合名单上引用。 如我所描述的那样,如果你不知道如何使$>ids>变数,那么你就需要读到一些网址。 它基本.。

否则,你的文字就应当发挥作用。 但是,正如有人在评论中指出的,你有许多带有空白的多余的法典,你可以删除其中的大部分。





相关问题
Angle brackets in php

I want to store angle brackets in a string in PHP because i want to eventually use mail() to send an HTML email out. The following is the code that doesn t seem to work. while(...) { $msg .= "<...

authlogic auto_register feature using my options

I have auto registration working with authlogic using gaizka s version of authlogic_openid which I found on Github since pelle s original addition of the feature seemed to cause issues. http://...

Zend 邮件问题,涉及外国char子+ com子

泽斯德邮局在名称被定为具有外国性质(如“保”)和 com(”)的物品时,就放弃了一种例外(因为邮局(邮局)退回假)。 重新提出以下守则。

How to track an email in Java?

How I can track an email? I m using java on the server side for sending emails. I want to track whether it is delivered , opened, etc... How I can do that ?

Web Link in a mail is not rendering as link in yahoo

string from = "abc@gmail.com"; string to = "xyz@gmail.com,xyz@yahoo.co.in"; string password="abcxyz"; MailMessage mail = new System.Net.Mail.MailMessage(); mail.To.Add(to); mail.From = new ...

SharePoint - Approaching Website Storage Limit Email

How can i go about changing the distribution list as well as the email text for the email that goes out to site collection admin when a site collection approaches it s size limit? Thanks for your ...

How to create an email mailing list

Im creating a coming soon page for a website im developing, and im adding an option for the user to enter their email address so we can email them when the site is up. How do I do this?

CCNet email does not include MSBuild results

We re using CCNet 1.4.4.83 but when an MSBuild task fails, we don t get the MSBuild results (i.e. missing file or whatever reason the compile failed) in the email notification. I do see the build ...