Page 1 of 1

Mailout Questions

Posted: Fri Jun 20, 2003 10:46 am
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.

Posted: Fri Jun 20, 2003 11:16 am
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?

Posted: Fri Jun 20, 2003 11:25 am
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.

Posted: Fri Jun 20, 2003 11:28 am
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.

Posted: Fri Jun 20, 2003 11:47 am
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.

    Posted: Fri Jun 20, 2003 11:52 am
    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.

    Posted: Fri Jun 20, 2003 11:53 am
    by releasedj
    not possible. That depends on the client software.

    Posted: Fri Jun 20, 2003 11:57 am
    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?

    Posted: Fri Jun 20, 2003 12:00 pm
    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.

    Posted: Fri Jun 20, 2003 12:13 pm
    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.