Jump to content

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 <blog@example.com>');
$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 <richard@example.com>');
    $mail->setSubject('Test email');
    $mail->setCc('fred@example.com');
    $mail->setBcc('barney@example.com');
    $mail->setText('Sample text');
    $result  = $mail->send(array('foo@goo.com'));

 

instead of sending one mail to foo@goo.com , 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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.