It’s been years since the first time I setup a mail server, and now the time has come again, I setup email address called info@mydomain.com on a friends server, and a php script called mailx1 to send the email with, but the email sent by the script end’s up in the users spam box, before we solved it with a simple message “check your spam” but now I want to finally solve this.
the server’s ip is 82.165.46.217
php script
function mailx1($to, $subject, $message, $htmlmessage=NULL) {
if (NULL==$htmlmessage) {
$headers .= "Reply-To: NightSmile.com <info@domain.com>\\r\
";
$headers .= "Return-Path: NightSmile.com <info@domain.com>\\r\
";
$headers .= "From: NightSmile.com <info@domain.com>\\r\
";
$headers .= "Organization: NightSmile.com\\r\
";
$headers .= "Content-Type: text/plain\\r\
";
$headers .= "MIME-Version: 1.0\\r\
";
$headers .= "X-Mailer: php";
ini_set('sendmail_path', '/usr/sbin/sendmail -t');
ini_set('sendmail_from', 'info@domain.com');
ini_set("SMTP","smtp.nightsmile.com" );
if(@mail($to, $subject, $message, $headers)) {
return TRUE;
} else {
return FALSE;
}
} else {
// Generate a boundary string
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
$headers = "From: NightSmile.com <info@domain.com>\\r\
";
$headers .= "Reply-To: NightSmile.com <info@domain.com>\\r\
";
$headers .= "Return-Path: NightSmile.com <info@domain.com>\\r\
";
$headers .= "From: NightSmile.com <info@domain.com>\\r\
";
$headers .= "Organization: NightSmile.com\\r\
";
$headers .= "MIME-Version: 1.0\\r\
";
$headers .= "Content-Type: multipart/alternative;
boundary=\\"$mime_boundary\\" charset=\\"utf-8\\"\\r\
";
$headers .= "Content-Transfer-Encoding: 8bit\\r\
";
$message = '--'.$mime_boundary."\\r\
Content-Type: text/plain; charset=\\"utf-8\\"\\r\
Content-Transfer-Encoding: 8bit\\r\
".$message.'--'.$mime_boundary."\\r\
Content-Type: text/html; charset=\\"utf-8\\"\\r\
Content-Transfer-Encoding: 8bit\\r\
".$htmlmessage;
ini_set('sendmail_from', 'info@domain.com.com');
if (@mail( $to, $subject, $message, $headers )) {
return TRUE;
} else {
return FALSE;
}
}
}
replace @domain.com with @nightsmile.com
this is a new server and has never sent a email before.