help with mail

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sunny77
Forum Newbie
Posts: 1
Joined: Tue Nov 12, 2002 1:53 pm

help with mail

Post 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.
Shadough
Forum Newbie
Posts: 20
Joined: Tue Jun 04, 2002 9:11 pm

Post 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");
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post 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! :(
User avatar
musashi
Forum Commoner
Posts: 39
Joined: Tue Jul 23, 2002 12:51 pm
Location: Santa Cruz - CA

Another idea

Post 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!
cctrax
Forum Commoner
Posts: 36
Joined: Thu Jul 11, 2002 9:05 pm
Location: United States
Contact:

Post 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 ;)
Post Reply