Jump to content

PHP Successful mail


Schlo_50

Recommended Posts

Hi there guys,

 

I developed a mail script quite a while ago now and i've been using it ever since. Recently though as people are using more and more spam protection my mails occasionally don't come through. For example, people with outlook express that have spam protection have settings applied that will automatically delete mail if it appears to be spam.

 

Im wondering if there is anything I can do to my script or any tricks etc that will ensure my legitimate mail gets into the inboxes of the recipients? My script is below for anyone wanting to take a look. Im just not sure if my script is outdated now?

 

<?php
$smtpset = '0';

$rootaddress = '[email protected]';

$from = "[email protected]";

$site = "[email protected]";

$name = stripslashes($_POST['a']);
$email = stripslashes($_POST['b']);
$comments = stripslashes($_POST['d']);
$comments = str_replace("\n", "<br>", $comments);

$flag = "yay";
$error = "";

if ($name == ""){    
$msg = $msg."Please enter your name.<br />";
$flag = "nay";  
}

if ($email == ""){    
$msg = $msg."Please enter an email address.<br />";
$flag = "nay";  
} 

if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { 
$msg = $msg."Please enter a valid email address.<br />";
$flag = "nay";
} 

if ($flag <> "yay"){
echo "$msg <br /> <input type='button' value='Retry' onClick='history.go(-1)'>";
}else{

$subject = "Enquiry";
$messagebody = "
You have received a booking enquiry from your website.

Name: $name
Email: $email

Comments:
$comments
";

if($smtpset == '0'){
  ini_set("sendmail_from", $rootaddress);
}

$headers = "From: $from";
mail($site, $subject, $messagebody, $headers);

echo "Thank-you for your enquiry. We will get back to you soon!";
}
?>

 

Thanks in advance guys, looking for suggestions and ideas!

Link to comment
https://forums.phpfreaks.com/topic/108852-php-successful-mail/
Share on other sites

Thats not it at all. Im just wondering if there is anything I can so in terms of headers maybe that might help against going straight to the spam box.

 

have your recipients add you to their contact list. That should save you from hitting the junk drawer.

 

Thats not really practical for the sorts of things you use generated mail for. Your website would look stupid if you had to instruct users to add your email address to their address books before registering to the site because if they don't they might not receive their login credentials..

Link to comment
https://forums.phpfreaks.com/topic/108852-php-successful-mail/#findComment-558418
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.