|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Mass mail with php
A while back I wrote a script to mass mail all the members on my writing site. I tested it on about 20 names to make sure it worked, and it does.
Now, I have a couple of practical questions about it. First here is what I do with the code, pseudo style. select email from members; while send email to $email $count++ echo $email $count echo You just sent email to $count people Now, I use @ to supress errors using mail. Some users didn't use valid email addresses in the old days ( I force that now ). So, I have two questions.. 1. If the email is not valid on a user will it cause the script to abort? Or since I use the @ will it continue to the next name. 2. I have less than a 1000 names. Would my script be able to send that many without running out of memory? Or should I select 100-200 at a time, use an offset and meta refresh? This does not have to be an elegant solution. I only mass email the users 1 time per year as a reminder that we exist and of all the major changes in the last year. |
|
#2
|
|||
|
|||
|
that's not a big deal
as far as the memory goes, you should be able to run it pretty easily.
when PHP suppresses an error, it just means that the error message is not displayed to the user. however, so long as the mail can leave your smtp server (which isn't dependant on a correct email address), you should be fine... if you get an error, it will be from some other physical server, and it won't be a PHP error because the mail couldn't be delivered. Just a little advise, try something like this to build your mail: PHP Code:
|
|
#3
|
|||
|
|||
|
yes, you can send your emails using the while statment, if one fails, it will move onto the next one, in regards to the 1000 names, it would probally put a big strain on your server and may even crash it, you might have to refresh the page after say 50 emails to stop if from happening
|
|
#4
|
|||
|
|||
|
Is it also possibel to use the CC: or BC: in the mail function?
Do you have to use the extraheader for this? like: from: URL, bc: address1; address2 ? |
|
#5
|
|||
|
|||
|
I would not recommend using the mail() function in PHP for anything over 100 mails, not even using it by breaking out your recipients in batches of 25, 50, 100 etc. and looping with the function. The mail function in general is pretty weak - your best option would be to open a socket to SMTP and package up the mail in an env and send it at once by using 'RCPT TO:' in the SMTP connection. Make your connection by using fsockopen() or popen(). Look through the user notes on fsockopen() and you will see a few examples of sending mail to SMTP using this...
__________________
~ Joe Penn We work for free to help make this a valuable resource on the internet. Do you appreciate the help - did we provide help that will help you prosper and help that has contributed to sharpening your current skill set? Show your appreciation and purchase something from our Amazon Wishlist's - it's simple and a great way to say thank you. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > Mass mail with php |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|