Mailout Questions

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
User avatar
gurjit
Forum Contributor
Posts: 314
Joined: Thu May 15, 2003 11:53 am
Location: UK

Mailout Questions

Post by gurjit »

Hi everyone

I'm trying to do a mailout to 8000 email addresses. I wanted to know if their is anyway that php can validate the email addresses to see if they exist before the mail is sent.

also is their away that php can see whether the mail box excepts html messages and if not then a text email is sent out.

can anyone give any other good hints about php and mailouts...i'm a newbie to php.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

PHP can't check whether emails really exist - it can only validate them according to specified pattern.

If you google a bit, you'll sure find some nice regular-expression libraries which have an email-validation function.

Unless you have your own mailserver, it's very likely that your hosting company's smtp-server has a floodcheck, meaning you can't send all those 8000 emails out at once.

You are using this for a newsletter - not for unsolicited emails (i.e. spam), right?
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Post by nielsene »

Well it is possible to use getmxrr and gethostbyname to check that the domain is legit and in some cases that a user account by that name exists.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

True, but validating the DNS-entry doesn't mean that the email is valid. However, checking DNS-entry is probably as far as one can push it with that.

That and a regEx email-check should eliminate most of the invalid addresses.
User avatar
releasedj
Forum Contributor
Posts: 105
Joined: Tue Jun 17, 2003 6:35 am

Post by releasedj »

OK, to check that an email is valid you have to:
  1. getmxrr() the domain to get a list of mx servers.
  2. try opening a socket to each mx server on port 25 (SMTP) until one responds
  3. send the correct SMTP commands to handshake with the server, i.e., EHLO, MAIL FROM... etc.
  4. Send RCPT TO command to server. If response is 250, then the email is valid.. well it could be a catch-all, but it is at least a mailbox that can accept emails
All this however, is alot to do for each email, it will take ages.
    User avatar
    gurjit
    Forum Contributor
    Posts: 314
    Joined: Thu May 15, 2003 11:53 am
    Location: UK

    Post by gurjit »

    ok then people how about checking whether the mail box accepts html or text messages. how can i achieve this?

    i think its better not to do the email checks....if its going to take long.
    User avatar
    releasedj
    Forum Contributor
    Posts: 105
    Joined: Tue Jun 17, 2003 6:35 am

    Post by releasedj »

    not possible. That depends on the client software.
    User avatar
    gurjit
    Forum Contributor
    Posts: 314
    Joined: Thu May 15, 2003 11:53 am
    Location: UK

    Post by gurjit »

    why is it that asp and coldfusion can do this?

    asp upload has features to check this....i would have thought that php would have had some type of feature to check whether the mail account allows html emails.

    what if out the 8000 mailouts...only half allow html to be displayed. is their away around this. does php automatically make an attachment file out the html that is sent?
    User avatar
    releasedj
    Forum Contributor
    Posts: 105
    Joined: Tue Jun 17, 2003 6:35 am

    Post by releasedj »

    I'm pretty sure that there isn't a way. It's like saying that PHP can tell whether JavaScript is enabled. It can't BTW.
    User avatar
    patrikG
    DevNet Master
    Posts: 4235
    Joined: Thu Aug 15, 2002 5:53 am
    Location: Sussex, UK

    Post by patrikG »

    ASP can not only check whether an email-address truly exists on a server but also whether the client accepts HTML- or text-emails?

    Unless the user has specified that when subscribing to the newsletter (or whatever it is you're sending out) I find that hard to imagine in any server-side scripting language - as releasedj said, it depends on the email-client.
    Post Reply