Jump to content

Multiple Emails


gavin.sibley

Recommended Posts

How many email addresses are you wanting to send at once?

If it is just to one extra email address just call the mail function twice specifying a different to variable for the second email,

If its many addresses you need to put it in a loop, but you also need to be careful not to send to many emails at once or you can get yourself blacklisted or blocked by your host for spam, the way around that is to incorporate a pause between blocks of say 10 at a time for example emails.

Link to comment
Share on other sites

Try something like this

 


<?php

//this is the email id which you pull form your database.
$to = $slide[email];

//this is the another email that you want to send the email.
$another = "example@example.com";

//sending the email with php mail() function

//1st sending the mail to the email id which you pull from database.

if(mail($to,$subject,$message,$headers)) {

//2nd sending the mail to the email id which you given as $another variable if the 1st mail is success.
mail($another,$subject,$message,$headers);

}
else {
echo 'Email not sent to';

}

?>

 

 

 

 

[/code]

Link to comment
Share on other sites

How many email addresses are you wanting to send at once?

If it is just to one extra email address just call the mail function twice specifying a different to variable for the second email,

If its many addresses you need to put it in a loop, but you also need to be careful not to send to many emails at once or you can get yourself blacklisted or blocked by your host for spam, the way around that is to incorporate a pause between blocks of say 10 at a time for example emails.

No, don't loop the mail function to send the same message to multiple recipients. Either add a cc or bcc header to the mail that you are sending. Or just add multiple addresses in the to header seporated with either commas or semi-colons depending on the mail servers setup.

Link to comment
Share on other sites

The idea of the loop is really for a newsletter function of a site, not for a couple of emails, I had no idea which he was trying to achieve as he said he was pulling emails from a database, so I mentioned both options

newsletters should either be fed using rss/atom/etc to client subscriptions (most every mail client supports RSS feeds) or if going as a mail item, bundled in the bcc using the multiple address method with a single message to a dummy address in the to header.  This reduces server load and network bandwidth.

Link to comment
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.