Hi
I am new to PHP development, I have to develop an email sender to a large list. I have two concerns.
1) I am using server mail() function to send mails , but as I dont want every body's name to be shown in "To" list I am calling mail () function in a loop passing each email address at a time. This doesnt seems to be efficient. Is there any other good way.
2) some mail servers cannot receive html mail and they either reject mail or show html tags in content. How can this problem be overcome.
help with mail
Moderator: General Moderators
Try using "Bcc" in mail() ?
http://php.net/manual/en/ref.mail.php
eg:
http://php.net/manual/en/ref.mail.php
eg:
Code: Select all
mail($to, $subj, $message, "Bcc: user@domain.com, another@a.com, yet@another.com");- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
For the second problem - give people a choice when they sign up to your mailing list as to whether they would like HTML or plain text e-mails from you as even people who can have HTML mails don't always want them. Then you can do two mailshots, one for the HTML e-mails and one for the plain text ones. For those people who are already on your mailing list send them a plain text email offering them the chance to choose which format they'd like.
Mac
Mac
Another idea
This may seem like overkill but I had a similar problem a little while ago. If you do a loop, Oromian is right, it will take too long. My solution eventually was to create a secondary mailman program. Basically the mailman was a script that ran as a cgi program (I did it in PHP, but PERL or any other language is fine) that received a bulk list of address, along with all the other details of the message (subject, from, etc.) It then performed the mail loop.
The main point with sending the work to the cgi program is that you can fork out the action, so that the web page can reload and the user can go about their way... (meaning the user doesn't need to sit and wait for the loop to complete, or worse, get a timeout error).
You've unfortunately uncovered a valid, and highly frustrating reality in performance early on in your PHP work!
The main point with sending the work to the cgi program is that you can fork out the action, so that the web page can reload and the user can go about their way... (meaning the user doesn't need to sit and wait for the loop to complete, or worse, get a timeout error).
You've unfortunately uncovered a valid, and highly frustrating reality in performance early on in your PHP work!
I think I have you beat. Way back when, I was attempting to do the same thing. It was late, I was tired, and I ended up sending myself a few hundred emails before I manually stopped the scriptOromian wrote:For the first problm, if you loop the mail() func and grab a new email each new looping row, there should only be 1 address in the from address, but as you said, it is NOT efficent. It took 25 mins to email 250 for me on my server. HORRIBLE!