Jump to content

mail not looping


sniperscope

Recommended Posts

Hi gurus.

I am trying to write some sort of mail magazine system.

I am getting registered mail addresses and assign into an array and try send them but my code send only the first record of array.

What is wrong with this code?

Any help will be great appreciate.

 

Regards

 

Note: my hosting is on win server.

 

$GetMailList = mysql_query("SELECT mailaddress FROM maillist WHERE GroupID = '$_POST[GrpID]' ORDER BY id ASC", $cn);
while($i = mysql_fetch_array($GetMailList)){			
$to[]     = $i['MailAdd']; // this is array for let's 20 mail addresses
}

require_once('Rmail.php');
$mail = new Rmail();
$mail->setFrom('Weeklynews <[email protected]>');
$mail->setSubject($title);
$mail->setText($body);
$result  = $mail->send($to[]);

Link to comment
https://forums.phpfreaks.com/topic/203045-mail-not-looping/
Share on other sites

1. Are you sure you are getting multiple email addresses from the database?

2. It is either $i['mailaddress'] or you need to select MailAdd from the database. <<Answered

3. I assume $mail->send() supports array's. <<Asked.

4. Does your host allow multiple emails?

Link to comment
https://forums.phpfreaks.com/topic/203045-mail-not-looping/#findComment-1063941
Share on other sites

mrMarcus thank you for your interest

 

i dont know why, but i think array has problem because orriginal code was like below and i edited it.

 

here is the original code of Rmail.php class

 

require_once('Rmail.php');

    /**
    * Now create the email it will be attached to
    */
    $mail = new Rmail();
    $mail->setFrom('Richard <[email protected]>');
    $mail->setSubject('Test email');
    $mail->setCc('[email protected]');
    $mail->setBcc('[email protected]');
    $mail->setText('Sample text');
    $result  = $mail->send(array('[email protected]'));

 

instead of sending one mail to [email protected] , i put all mails into $to[].

Link to comment
https://forums.phpfreaks.com/topic/203045-mail-not-looping/#findComment-1063942
Share on other sites

thanks for you help guys. I solved my problem.

Solution was very simple. I sent 200 mail at same time to same mail server (let's say hotmail) and server was accept first mail then figured out rest 199 mails are spam. That's why my mails did not reach all subscribers. I passed this problem with sleep(60); Now all mails deliver to users.

 

Thank you very much for all of you who interested.

 

PS: how can i change header to SOLVED ?

Link to comment
https://forums.phpfreaks.com/topic/203045-mail-not-looping/#findComment-1064909
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.