944,052 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Marked Solved
  • Views: 573
  • PHP RSS
Nov 4th, 2009
0

Question about mass mail function

Expand Post »
Hey all,

I need to use the PHP mail() function in order to send an email to a number of individuals.

So lets say that I have 5 users that need to get a particular email. I was thinking that the correct way of going about using the mail() function, would be:
1) to create an array variable

2) load the 5 usernames in the array

3) then store in a variable the size of the array, i.e. in my example it is 5 positions.

4) make a for loop with its limit whatever the array size is...

5) for each iteration read the corresponding username from the array and use the mail() function to email that specific username...

The point is, does anyone know of any other function other than mail() that can take more than one recipients? That would be really helpful and actually it would be more optimal and save server time... I created a massml() function myself and it takes as recipient an array argument, it works with the specifications that I gave above. But I am using a loop inside my function so this is still the same as looping the mail() function... It's not much of a problem but the optimality of this has been bugging me since morning.

Thanks for listening, I appreciate any answers,

George
Last edited by violarisgeorge; Nov 4th, 2009 at 7:55 pm.
Similar Threads
Reputation Points: 10
Solved Threads: 3
Newbie Poster
violarisgeorge is offline Offline
15 posts
since May 2009
Nov 4th, 2009
0
Re: Question about mass mail function
You can specify BCC addresses in the mail function, but that way would not allow you to send personalised emails..

As far as I am aware, mail would be the best way to do this.
Reputation Points: 96
Solved Threads: 124
Master Poster
Will Gresham is offline Offline
728 posts
since May 2008
Nov 4th, 2009
0
Re: Question about mass mail function
Hey.

You should check out PHPMailer or Swift Mailer.
Both are much easier to deal with than the PHP mail function, and both allow for multiple recipients.

But if you don't want that, the steps you describe for you mail script looks OK. At least on paper
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 4th, 2009
1
Re: Question about mass mail function
As an afterthought...
The mail function does allow for multiple recipients for one call.

If you pass something like User1 <user1@example.com>, User2 <user2@example.com> as the first parameter, the mail would be sent to both recipients.

See the to parameter description and example #4 in the manual.
Reputation Points: 93
Solved Threads: 70
Posting Pro
Atli is offline Offline
526 posts
since May 2007
Nov 4th, 2009
0
Re: Question about mass mail function
Click to Expand / Collapse  Quote originally posted by Atli ...
As an afterthought...
The mail function does allow for multiple recipients for one call.

If you pass something like User1 <user1@example.com>, User2 <user2@example.com> as the first parameter, the mail would be sent to both recipients.

See the to parameter description and example #4 in the manual.
Hmmm, yeah, thanks for the link to the spec! So cool, no loops or anything needed, also I could store the recipients as a string var resulting from an array maybe... I should try this in the morning when I wake up, as this would allow for automatically populating the recipients!

Thanks, I'll check in the morning as I said and get back at this!
Reputation Points: 10
Solved Threads: 3
Newbie Poster
violarisgeorge is offline Offline
15 posts
since May 2009

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: need help with table
Next Thread in PHP Forum Timeline: extract from a string





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC