Page 1 of 1

help with mail

Posted: Tue Nov 12, 2002 1:53 pm
by sunny77
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.

Posted: Wed Nov 13, 2002 12:54 am
by Shadough
Try using "Bcc" in mail() ?

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");

Posted: Wed Nov 13, 2002 2:49 am
by twigletmac
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

Posted: Wed Nov 13, 2002 10:19 am
by m3mn0n
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! :(

Another idea

Posted: Wed Nov 13, 2002 6:25 pm
by musashi
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!

Posted: Wed Nov 13, 2002 8:50 pm
by cctrax
Oromian 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! :(
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 script ;)