communication
|send email
email sending function with email address validator
full source of send email [ line 1 - 29 ] | download send email
| 1 | <?php |
| 2 | // checks the syntax of the emailaddress |
| 3 | function funcCheckEmail($sEmailAddress) |
| 4 | { |
| 5 | $sChars = "^[A-Za-z0-9._-]+@([A-Za-z][A-Za-z0-9-]{1,62})(.[A-Za-z][A-Za-z0-9-]{1,62})+$"; |
| 6 | $bIsValid = true; |
| 7 | if(!ereg("$sChars",$sEmailAddress)) |
| 8 | { |
| 9 | $bIsValid = false; |
| 10 | } |
| 11 | return $bIsValid; |
| 12 | } |
| 13 | // sends the email |
| 14 | function funcSendEmail($recipient,$subject,$message,$from,$replyto) |
| 15 | { |
| 16 | $array = array ("'" => "'"); |
| 17 | $message = strtr($message, $array); |
| 18 | $message = '<html><body>'.$message.'</body></html>'."rnrn"; |
| 19 | $extra = 'From: '.$from.' <'.$replyto.'>'."rn"; |
| 20 | $extra .= 'Content-Type: text/html; charset="ISO-8859-1"'."rn"; |
| 21 | $extra .= 'Content-Transfer-Encoding: quoted-printable'."nrn"; |
| 22 | mail ($recipient, $subject, $message, $extra); |
| 23 | } |
| 24 | // use like this |
| 25 | if((funcCheckEmail('recipient@example.com')) && (funcCheckEmail('sender@example.com'))) |
| 26 | { |
| 27 | funcSendEmail('recipient@example.com','Re:Re:...','how are you','john foo','sender@example.com'); |
| 28 | } |
| 29 | ?> |
9 hits by 7 users in the last 30 minutes.