<?php
$url=array();
$sender='ABSENDERADRESSE';
$url=@explode("@",$_GET['address']);
if(!isset($_GET['address']) || empty($url) || count($url)!=2 || trim($url[0])=='' || trim($url[1])==''){
die('Keine Emailadresse angegeben z.B. <strong>?address=you@domain.tld</strong>');
}else{
gethostbyname($url[1])!=$url[1]?$url[2]=gethostbyname($url[1]):$url[2]=false;
if($url[2]===false){
die('Es konnte keine IP zu Host <strong>'.$url[1].'</strong> gefunden werden');
}
$mx = array();
$t = getmxrr($url[1],$mx);
if(count($mx) > 0){
$mx = $mx[0];
}else{
$mx = $url[1];
}
$head.= "From: <{$sender}>\r\n";
$head.= "To: <{$url[0]}@{$url[1]}>\r\n";
$head.= "Subject: Einen lieben Gruss\r\n\r\n";
$head.= "Salut {$url[0]}, alles klar?\r\n";
$head.= ".\r\n";
$fp = @fsockopen($mx,2525,$errno,$errstr,5);
if(!$fp){
die('Konnte keine Verbindung zu '.$mx.' aufbauen.<br />Meldung: '.$errstr.' ('.$errno.')');
}
$ret[] = fgets($fp,1024);
$ret[] = "HELO YOUR_HOST\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
$ret[] = "MAIL FROM: <{$sender}>\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
$ret[] = "RCPT TO: <{$url[0]}@{$url[1]}>\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
if(strpos($ret[count($ret)-1],"5") === 0 || strpos($ret[count($ret)-1],"4") === 0){
$ret[] = "QUIT\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
fclose($fp);
$fp = false;
}
if($fp !== false){
$ret[] = "DATA\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
if(strpos($ret[count($ret)-1],"5") === 0 || strpos($ret[count($ret)-1],"4") === 0){
$ret[] = "QUIT\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
fclose($fp);
$fp = false;
}
}
if($fp !== false){
$ret[] = false;
fputs($fp,$head);
$ret[] = fgets($fp,1024);
$ret[] = "QUIT\r\n";
fputs($fp,$ret[count($ret)-1]);
$ret[] = fgets($fp,1024);
}
for($i=0;$i<count($ret);$i++){
if($ret[$i] === false && $fp !== false){
echo '<table><tr valign="top"><td><strong>IN: </strong></td><td>'.nl2br(htmlentities($head)).'</td></tr></table>';
continue;
}
if($i==0 || $i%2==0 ){
echo 'OUT: <strong>'.nl2br(htmlentities($ret[$i])).'</strong>';
}else{
echo '<strong>IN:</strong> '.nl2br(htmlentities($ret[$i]));
}
}
if($fp !== false){
fclose($fp);
}
}
?>