WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDES  |  PHP CLASSES  |  CODE SEARCH  |  ARTICLES SEARCH  |  PHP FORUMS  |  PHP MANUAL  |  PHP FUNCTIONS LIST  |  WEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Submit Your Code
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
WeberDev's Monthly code contest PHP Code Contest
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Index
PHP Web Logs (BLogs)
Web Development Resources
Web Development Content
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
Submit Site
Forex Trading Online forex trading platform

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : X-Mailer, this php3 script verifies recipient address in three different ways before it sends email. All in one document. Report satus when mail sent.
Categories : PHP, Email, HTML and PHP Update Picture
tobozo tagada
Date : Oct 29th 1999
Grade : 3 of 5 (graded 1 times)
Viewed : 5565
File : mailpack.zip
Images : No Images for this code example.
Search : More code by tobozo tagada
Action : Grade This Code Example
Tools : My Examples List

  Submit your own code examples 
 

X-Mailer, this php3 script verifies recipient address in three different ways before it sends
email. All in one document.
Supports CC, BCC, Reply-to and Soon Attached files.
Gives a full report of the transaction when finished.
Easily customizable, feel free to morph it to your needs.
The script can be downloaded from this address :
http://www.1st-home.net/Computers/legang/xmailer.zip

tobozo@biosys.net


Here is the code :

<?
// X-mailer for PHP3
// Excuse my french, but English is not my native language.
// Okay, I wrote this script, but 60% is copy/pasted/modified from others.
// Finished 29-10-99 By Tobozo tobozo@biosys.net from pieces of scripts
// found everywhere on the internet :
// http://www.dells.com/ , http://www.tuna.org , http://www.phpwizard.net
// http://www.php.net etc etc etc
// The ValidateEmail function is used, thanx to Jon S. Stevens jon@clearink.com
// and Shane Y. Gibson shane@tuna.org for that part.
// The JavaScript code for email syntax verification is from phpwizard.net (validator)
// Thanx to Tobias Ratschiller (never spoke to him but thanx anyway).
// Actually the script doesnt verify the CC, BCC, and FROM fields
// because it sometimes gives a timeout... could work on it.
// The attached files are not sent (not event in the code hehehe).
// Whoever wants to modify this is welcome (dont forget to send me
// the updated version).
//
// Todo
//
// Implement BCC, FROM and CC verification by using frames
//
// Implement attached files and Embedded HTML tags
//
// Implement a list to provide a header choice in the messages
// (possibly to "lie" on the mail client-version
//
// Your ideas
//
// you are free to copy/modify/spread this code as long as you keed the credits
// to the contributors (list is getting bigger).
// Enhancements ideas, updates, insults, send email to : tobozo@biosys.net
//
// USE but dont ABUSE



// Uncomment this line and put the full URL of your document if you
// get problems with the script.

// $url="http://your.domain.com/your_path/this_script_filename.php3";

if (!$mail)
        {
        ?>
        <script language="JavaScript"><!--
         function ContainsSomething(Field)
         {
         if ((Field.type == "text") || (Field.type == "textarea"))
         {
         if (Field.value == "")
         {
         return false;
         }
         }
         else
         {
         if (returnSelection(Field) == null)
         {
         return false;
         }
         }
        
         return true;
         }
         function IsValidEmail(Field)
         {
         if (!ContainsSomething(Field))
         {
         return false;
         }
         if (Field.value.indexOf("@")==-1
         || Field.value.indexOf(".")==-1
         || Field.value.indexOf(" ")!=-1
         || Field.value.length<6)
         {
         return false;
         }
         else
         {
         return true;
         }
         }
        function CheckForm()
         {
         if (!IsValidEmail(document.forms[0].mailfrom))
         {
         alert ("Invalid Sender !");
         return false;
         }
         if (!IsValidEmail(document.forms[0].mailto))
         {
         alert ("Invalid Recipient !");
         return false;
         }
         if (!ContainsSomething(document.forms[0].msg))
         {
         alert ("A required Field is Empty !");
         return false;
         }
         return true;
         }
        
        // --></Script>
        <body bgcolor=#202020 text=yellow>
        
        <centeR><BR><BR>
        
        <table width= 460 bgcolor=#c0c0c0 cellpadding=8 cellspacing=3>
        
        <tr><td bgcolor=000000 valign=top>
        
        <p align=justify><font color=yellow size=+2><B>X-mailer-z no-(c) The savate<BR>
        <font size=-1 face=tahoma>The purpose of this PHP3 Script is to send anonymous
(no so much in fact) email using the sendmail of the web server. It verifies if the recipient
exists by connecting on the smtp and performing a HELO/RCPT TO:. If answer is 250, mail is
sent. If not .. . who knows ?
        </td><td bgcolor=000000>
        
        <centeR><img src=images/savate.gif height=110 width=110></td></tr></table>
        
        <form onSubmit="return CheckForm();"<? if ($url) echo "action=\"$url\""; ?>>
        
        <table width=460 bgcolor=#c0c0c0 cellpadding=3 cellspacing=3>
        <tr><td bgcolor=000000><font color=yellow>
        
        <B>From : </td><td bgcolor=000000><font color=yellow><input type=text
name="mailfrom" size=20 maxlenght=100></td><td bgcolor=000000><font color=yellow>
        
        <B>To : </td><td bgcolor=000000><font color=yellow><input type=text
name="mailto" maxlenght=100 size=20></td></tr><tr><td bgcolor=000000><font
color=gray>
        
        <B>CC : </td><td bgcolor=000000><font color=yellow><input type=text
name="cc" maxlenght=100 size=20></td><td bgcolor=000000><font color=gray>
        
        <B>BCC : </td><td bgcolor=000000><font color=yellow><input type=text
name="bcc" maxlenght=100 size=20></td></tr><tr><td bgcolor=000000><font color=gray
size=-2 face=verdana>
        
        <B>Reply to : </td><td bgcolor=000000><font color=yellow><input type=text
name="replyto" maxlenght=100 size=20></td><td bgcolor=000000><font color=gray size=-
2 face=verdana><B>File1:(n/a) </td><td bgcolor=000000><input type=file size=5
name="file1"></td></tr><tr><td bgcolor=000000><font color=yellow>
        
        <B>Subject : </td><td bgcolor=000000><font color=yellow><input type=text
name="subject" maxlenght=100 size=20></td><td bgcolor=000000><font color=gray size=-
2 face=verdana><B>File2:(n/a) </td><td bgcolor=000000><input type=file size=5
name="file2"></td></tr><tr><td colspan=4 bgcolor=000000><font color=yellow>
        
        <B>Message (1024 char. max):<BR><textarea name="msg" maxlenght=1024
rows=10 cols=50 wrap=soft></textarea>
        
        <input type=hidden name="mail" value="1"></td></tr><tr><td bgcolor=000000>
        
        <input type=submit value=envoyer></td><td colspan=3 bgcolor=000000><font
face=tahoma size=-1 color=yellow><B>
        
        <p align=right>no-(c) 1999 by the savate <a
href="mailto:tobozo@biosys.net">system</a>
        
        </td></tr>
        
        </table>
        
        </form>
        
        <?
        exit;
        }
        
        
else
        {
        $mailheaders = "From: ".$mailfrom."\n";
        $mailheaders .= "Cc: ".$cc."\n";
        $mailheaders .= "Bcc: ".$bcc."\n";
        $mailheaders .= "Reply-To: ".$replyto."\n";
        $mailheaders .= "X-Mailer : maileur masqued/savate\n";
        $mailheaders .= "X-Maileur : ze mailer with ze mask";

function validateEmail ( $email )
{
global $SERVER_NAME;
$return = array ( false, "", "", "" );
list ( $user, $domain ) = split ( "@", $email, 2 );
$arr = explode ( ".", $domain );
$count = count ( $arr );
$tld = $arr[$count - 2] . "." . $arr[$count - 1];
if ( checkdnsrr ( $tld, "MX" ) )
{
if ( getmxrr ( $tld, $mxhosts, $weight ) )
{
for ( $i = 0; $i < count ( $mxhosts ); $i++ )
{
$fp = fsockopen ( $mxhosts[$i], 25 );
if ( $fp )
{
$s = 0;
$c = 0;
$out = "";
set_socket_blocking ( $fp, false );
do
{
$out = fgets ( $fp, 2500 );
if ( ereg ( "^220", $out ) )
{
$s = 0;
$out = "";
$c++;
$return[2] = true;
$return[3] = $mxhosts[$i];
}
else if ( ( $c > 0 ) && ( $out == "" ) )
{
$return[2] = true;
break;
}
else
{ $s++; }
if ( $s == 9999 ) { break; }

} while ( $out == "" );
set_socket_blocking ( $fp, true );
fputs ( $fp, "HELO $SERVER_NAME\n" );
$output = fgets ( $fp, 2000 );
fputs ( $fp, "MAIL FROM: <info@" . $tld . ">\n" );
$output = fgets ( $fp, 2000 );
fputs ( $fp, "RCPT TO: <$email>\n" );
$output = fgets ( $fp, 2000 );
if ( ereg ( "^250", $output ) )
{
$return[0] = true;
}
else
{
$return[0] = false;
$return[1] = $output;
}
fputs ( $fp, "QUIT\n" );
fclose( $fp );
if ( $return[0] == true )
{ break; }
}
}
}
} else {
$return[0] = false;
$return[1] = "Invalid email address (baaad hostname)";
$return[2] = false;
}

return $return;
}


if (!$mailfrom)
        {
        echo "sender field empty !";
        exit;
        }

if (!$mailto)
        {
        echo "recipient field empty !";
        exit;
        }
if (!$subject)
        {
        echo "subject field empty !";
        exit;
        }
if (!$msg)
        {
        echo "message field empty !";
        exit;
        }

if ($mail)
        {
        $val_results = array( "", "" );
        $val_results = validateEmail( $mailto );
        if ( $val_results[0] == true )
                {
                $value = "<font color=\"green\"><B>valid !</b></font>";
                $commentaire = "<BR><B>Conclusion : <BR>Mail was probably sent (who
knows).</b>";
                }
        else
                {
                $value = "<font color=\"red\"><B>invalid !</b></font>";
                $commentaire = "<BR><B>Conclusion : <BR>Invalid email can be
explained by many things and doesnt mean the email was not sent : <BR><li>Smtp could be
down<li>Smtp is behind a firewall<li>This server could allow sendmail but not socks<li>The
user doesnt exist<li>The hostname doesnt exist<li>etc..etc..<br>Soo stop trusting this stupid
script and use your real email :-)</b>";
         }
        
        if (mail($mailto, $subject, $msg, $mailheaders)) echo "<h2>Mail SENT</h2>";
                
        print( "<body bgcolor=#202020 text=yellow><h2>Anonymailer (c) the
savate</h2>");
        print( "<h1>X-mailer-z no-(c) the savate</h1>");
        print( "<br>Transaction results:<br><br>" );
        print( "<pre>" );
        print( "(valid/invalid)          <font
color=\"white\">Value</font>: ".$value."<br>");
        print( "(true/false valid email) <font color=\"white\">Value</font>: ".$val_results
[0]."<br>");
        print( "(Code SMTP false) <font color=\"white\">Value</font>: ".$val_results
[1]."<br>");
        print( "(MX Host true/false) <font color=\"white\">Value</font>: ".$val_results
[2]."<br>");
        print( "(Answer from MX host) <font color=\"white\">Value</font>: ".$val_results
[3]."<br>");
        print( "</pre>" );
        print(         "<pre>True is 1 (un)<br>False is NULL (nothing)</pre><br>");
        print( "The email address <font color=\"white\"><tt>".$mailto."</tt></font>
is ".$value);
        print( $commentaire);
        }
        exit;
?>



PHP3: Formmail. Just a cgi formmail, but than in PHP. It is easy to use!
Categories : HTML and PHP, Email, PHP, Perl, HTML and PHP
PHP3 PHP POP3 SMTP MAIL
Categories : PHP, Email, HTML and PHP
PHP MultiList Mailing List Manager
Categories : Email, HTML and PHP, PHP
phpEasyMail: An easy way to send data from HTML-forms via EMail.
Categories : Email, HTML and PHP, Complete Programs, PHP
Message of the Day - Random Message (Needs MySQL!)
Categories : Databases, HTML and PHP, PHP, MySQL
a function that builds an HTML select list from any mysql table.
Categories : PHP, MySQL, HTML and PHP
Tag content retrieval from websites with preg_match
Categories : PHP, Regexps, Arrays, HTML and PHP
Check parameters validity. Paranoia was designed to check the validity of the parameters that a php page will receive after a form submission. It can be used to check the variables sent by POST or GET
Categories : Algorithms, HTML and PHP, PHP, Variables
email new items in db
Categories : PHP, Email, Databases, MySQL, Beginner Guides
Alternating background color for HTML table rows
Categories : PHP, Databases, MySQL, HTML and PHP
Constantly refresh your PHP/HTML page data.
Categories : PHP, HTML and PHP, Sybase
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
Automatically printing the contents of an sql table in MySQL.
Categories : MySQL, PHP, HTML and PHP, Databases
PHP template processing
Categories : PHP, Templates, HTML and PHP
background music script for random notes in a frame
Categories : PHP, Content Management, HTML and PHP