home about us contact us rates support resellers
InfoTeam - providing internet solutions from domain name registration to web site hosting to internet access to e-commerce
9.9¢/minute Conference Calling
order now
domain registration web hosting web design web promotion internet access
 Quick Domain Search:
InfoTeam.Net Home

Call Toll Free 1.877.819.0414
InfoTeam Supporti icon CONTACT SUPPORT
   Email      Web Hosting      Internet Access      Billing      |  System Status & Scheduled Maintenance
spacer.gif - 67 Bytes spacer.gif - 67 Bytes
i iconWeb Hosting Support
spacer.gif - 67 Bytes spacer.gif - 67 Bytes
spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes
spacer.gif - 67 Bytes spacer.gif - 67 Bytes

PHP - Email Hints

InfoTeam has PHP available on all hosting plans. The following are some suggestions for handling of email within PHP scripts. Email handling entails validating end user input of their email address into your forms for latter processing and also possibly sending email out to addresses that you have collected.

VALIDATING AN EMAIL ADDRESS
InfoTeam strongly recommends that at a minimum you incorporate functions 1 and 2, and possibly function 3 if you want to be thorough. Here is a review of valid characters in the local part of a mail address.

1) Some code to test these characters and the general format of the address:

function checkEmailString($email) {
   $regexp = "^([_\+a-z0-9-]+)(\.[_\+a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
   if ( eregi($regexp, $email) ) {
      return true;
   } else {
      return false;
   }
}

2) Some code to check for a valid domain. A failure here will likely mean a failure sending mail later:

function checkEmailDns($email) {
   list($username,$domain)=split('@',$email);
   if (!checkdnsrr($domain,'MX')) {
      return false;
   } else {
     return true;
   }
}

3) Some code to validate that a connection can be made to the domain's email servers. This can be problematic, so if you choose to implement this step, you may want an option for the user to 'override' any error:

function checkEmailServer($email) {
   list($username,$domain)=split('@',$email);
   $mxhosts = array();
   if (!getmxrr($domain, $mxhosts)) {
      if (!fsockopen($domain, 25, $errno, $errstr, 30)) {
         return false;
      } else {
        return true;
      }
   } else {
      foreach ($mxhosts as $host) {
         if (fsockopen($host, 25, $errno, $errstr, 30)) {
            return true;
         }
      }
      return false;
   }
}

SENDING AN EMAIL MESSAGE
InfoTeam strongly recommends that you include an "envelope from" address in your message. This should be the address of a person at your organization that can handle the inevitable errors and bounced email.

Some code to do this (you must populate the variables):

   // The following address may or may not be the same as the sender ($e_from)
   $env_from="person_that_handles_bounces@yourdomain.com";
   $e_headers="From: $e_from\r\n"."X-Mailer: PHP/".phpversion();

   $x = mail("$e_to", "$e_subject", "$e_msg", "$e_headers", "-f$env_from");

spacer.gif - 67 Bytes spacer.gif - 67 Bytes
spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes spacer.gif - 67 Bytes
return to top
Copyright
© 1996-2009 InfoTeam Corporation
All rights reserved worldwide
InfoTeam Hosting and Design Subscription Agreement
(Terms & Acceptable Use Policy)
InfoTeam's
Privacy Policy



Bannerco-op Banner Exchange Bannerco-op Banner Exchange
The Banner Co-op Exchange Free Advertising & Cash To Promote Your Site! Join Here!