Reply to Re: [PHP] weird mail function problem

Your name:

Reply:


Posted by Richard Lynch on 02/21/05 23:46

Ahmed Abdel-Aliem wrote:
> hi
> i use this code to send email from mysite
> but when it sends to some accounts it repeats the body part twice in
> the same email while to other accounts it sends the body one time only
> can anyone help in that plz ?
>
> if ($email_to != "") {
> $to = array();
> $to = explode (",", $email_to);
> $to_mum = count($email_to);
> for ($i=0; $i<$to_mum ; $i++){
> $to_email = $to[$i];
> $subject = $email_subject;
> $body .= $HTTP_POST_VARS['message'];

Right here, you begin adding stuff to $body

Which is fine (more or less) the FIRST time through, but every time you
loop back here for the next email, you add on the body *again*

So the second person has TWO copies, the third person has THREE, etc.

Change this line to NOT have the '.' in the '.=

You should also consider just sending ONE email with a Bcc: line to all
recipients.

This will be a lot more efficient if you need to send a LOT of copies at
once.

> $body .= "\n---------------------------\n";
> $body .= "Article Name :";
> $body .= "\n---------------------------\n";
> $body .= $Article_Name;
> $body .= "\n---------------------------\n\n";
> $body .= "\nStory :\n\n";
> $body .= $TheStory;
> $body .= "\n\n\n---------------------------\n";
> $body .= "Sent By: " . $HTTP_POST_VARS['email_address'] . "\n";
> $header = "From: " . $HTTP_POST_VARS['email_address'] . " <" .
> $HTTP_POST_VARS['email_address'] . ">\n";
> $header .= "Reply-To: " . $HTTP_POST_VARS['email_address'] . " <" .
> $HTTP_POST_VARS['email_address'] . ">\n";
> $header .= "X-Mailer: PHP/" . phpversion() . "\n";
> $header .= "X-Priority: 1";
> mail($to_email, $subject, $body, $header);
>
> --
> Ahmed Abdel-Aliem
> Web Developer
> www.ApexScript.com
> 0101108551
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация