Previously I have posted PHP email scripts here but here is an update that is working for me now. There is one common problem with the email that is sent by using PHP scripts. That is: Email land in junk or spam folder. Here is the solution with HTML ready email. Send PHP email with correct headers info, in HTML format that will not land in receiver’s junk folder or spam folder.
The problem seems to be with the From header. Use correct headers like below and you email will not be marked with spam.
<?php // $mailto=$txtEmail; // or $mailto="firstname.lastname@example.org"; $mailfrom="email@example.com"; $mailfrom2="myName <firstname.lastname@example.org>"; $subject= "Subject of email"; // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= "From: ".$mailfrom2."\r\n"; $headers .= "Reply-To: ".$mailfrom."\r\n"; $headers .= "Return-Path: ".$mailfrom."\r\n"; $headers .= "Signed-by: sitename.com"; // $headers .= 'Cc: email@example.com' . "\r\n"; // $headers .= 'Bcc: firstname.lastname@example.org' . "\r\n"; $mmessage = " <br /><br /> Hello <strong>Buddy</strong> <br /><br /> Thanks for joining my website. <br /><br /> More text and html code... <br /><br /> Your brand name <br /> <a href='https://www.mysite.com'>https://www.mysite.com</a> "; @mail($mailto, $subject, $mmessage, $headers); ?>