Here are my codes for sending mail:
$fullname = $_POST['fullname']; $email = $_POST['email']; $telephone = $_POST['telephone']; $email = $_POST['email']; $date = $_POST['date']; $time = $_POST['time']; $adult = $_POST['adult']; $children = $_POST['children']; $company_name = $_POST['company_name']; $addition = $_POST['addition']; $confirm = $_POST['confirm']; $body = ' <table width="100%" border="0" cellpadding="0"> <tr> <td>Dear Sir, </td> </tr> <tr> <td><b>Booking request from '.$fullname .'</b><br /><br /> <u>The details provided are:</u><br /> <p>Name : '.$fullname.'<br /> E-mail Address: '.$email.'<br /> Telephone: '.$telephone.'<br /> Date: '.$date.'<br /> Time: '.$time.'<br /> Adult: '.$adult.'<br /> Children: '.$children.'<br /> Company Name: '.$company_name.'<br /> Confirm by: '.$confirm .'<br /> Additional Requirements: '.$addition.'<br /> </p> </td> </tr> <tr> <td> <p>Thank you,<br /> Kaavya Cuisine </p></td> </tr> </table> '; $to = 'firstname.lastname@example.org'; $subject = 'Booking Request'; $sitename='Website Name'; $mail = new PHPMailer(); $mail->AddReplyTo($to,$sitename); $mail->SetFrom($email,$fullname); $mail->AddAddress($to, $sitename); $mail->Subject = $subject; $mail->MsgHTML($body); $mail->Send();
Every time I send the mail, it goes in to spam. Does anyone know why this is happening?
Based on you code i notice that you are sending an email directly from you web page on your domain.
For example you used an @hotmail.com address.
When the recipient receive the emails the mail service of the recipient may test a reverse DNS of the sender of the mail. So the sender is from
@hotmail.combut the mail comes from your domain which of course is not hotmail.com.
So I receive a mail from an address
@hotmail.combut the IP sender isn't related at all with domain hotmail.com: that's SPAM!
I think a possible solution is: in you PHP code use authenticate with SMTP and from there send the mail!