Question

I could really use your help on this one. I've written the following email form and it works with my own private domain email address (me@my-domain.co.uk), however, the corporate email address (me@work.com) must have a stronger spam filter as there not going through. I'm now looking to decrease the spam level by organising seperate MIME types, i.e. text/html and text/plain varying on the client side. I've looked at the following tutorial: http://www.tek-tips.com/faqs.cfm?fid=2681

The problem is that it makes no sense. Can anyone point me in the right direction to rectify the problem and inform me how to sort the seperate headers etc?

<?php
  {
  $to = "me@work.com, me@my-domain.co.uk";
  $subject = "Quotation Request from Work Website.";
  $headers = "Content-type:text/html;charset=iso-8859-1";
  $first_name = filter_input(INPUT_POST, 'first_name');
  $last_name = filter_input(INPUT_POST, 'last_name');
  $telephone = filter_input(INPUT_POST, 'telephone');
  $gotNumberFrom = filter_input(INPUT_POST, 'gotNumberFrom');
  $quoteFor = filter_input(INPUT_POST, 'quoteFor');
  $address = filter_input(INPUT_POST, 'address');
  $takenBy = filter_input(INPUT_POST, 'takenBy');

  $message = 
  "<span style='font-weight: bold;'>Name: </span>"."<br />".$first_name." ".$last_name."<br />"."<br />".
  "<span style='font-weight: bold;'>Telephone: </span>"."<br />".$telephone."<br />"."<br />".
  "<span style='font-weight: bold;'>Address of Works: </span>"."<br />".$address."<br />"."<br />".
  "<span style='font-weight: bold;'>Quotation for: </span>"."<br />".$quoteFor."<br />"."<br />".
  "<span style='font-weight: bold;'>Got our number from: </span>"."<br />".$gotNumberFrom."<br />"."<br />".
  "<span style='font-weight: bold;'>Quotation taken by: </span>"."<br />".$takenBy."<br />"; 

  mail($to, $subject,"<html>Hola!<br /> Please find details below of the individual that has requested a quotation Gaffer.<br />
      <br />" . $message . "</html>", $headers);
  echo "Your message has been successfully sent, here's a lollipop. <br />"?>
<?php  }
?>

Any help would be extremely appreciated!

Was it helpful?

Solution

The main reason behind the issue is improper headers, pass proper headers into your mail function and you'll be good to go. You can use the following example:

$headers  = "From: My site<noreply@example.com>\r\n";
$headers .= "Reply-To: info@example.com\r\n";
$headers .= "Return-Path: info@example.com\r\n";
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top