Jump to content

Bizarre Email Problem


linnington

Recommended Posts

I have a rather bizarre problem with a script I use for sending automated emails. The script is:

 

<?php
$formSubmitted = isset($_POST['submitted']);
$submitSuccess = false;
if (formSubmitted) {
function spam_scrubber($value) {
$very_bad = array('to:','cc:','bcc:','content-type:','mime-version:','multipart-mixed:','content-transfer-encoding:');
foreach ($very_bad as $v) {
if(stripos($value,$v) !== false) return '';
}
return trim(strip_tags($value));
}//end of spam_scrubber
$scrubbed = array_map('spam_scrubber',$_POST);
if (!empty($scrubbed['customerName']) && !empty($scrubbed['customerQuery']) && (!empty($scrubbed['phone']) || !empty($scrubbed['emailAddress']))) {
$submitSuccess = true;
if (!empty($scrubbed['emailAddress'])) {
$emailAddress = $scrubbed['emailAddress'];
if (!strstr($emailAddress,'@') || !strstr($emailAddress,'.')) {
$submitSuccess = false;
}
}
if ($submitSuccess) {
$body = "Customer's name: {$scrubbed['customerName']}\nCustomer's phone number: {$scrubbed['phone']}\nCustomer message: {$scrubbed['customerQuery']}";
$body = wordwrap($body,70);
$from = "no-reply@lbi-beach-house.com";
if (!empty($scrubbed['emailAddress'])) {
$from = $scrubbed['emailAddress'];
}
mail('my@emailaddress.com','Message via website from ' . $scrubbed['customerName'],$body,"From: ".$from);
header( 'Location: thank-you.php' ) ;
}
}
}//end of formSubmitted
?>

 

The problem is with the emailAddress submitted. During testing, if I use an email address from the domain @wsgfl.org.uk then the script fails to send the email (yet it redirects to the thank-you page). It's bizarre because I only have to change the submitted domain by one letter and it works. It seems to have nothing to do with the length of the address or the number of dots in the address.

 

Anyone got any ideas? I've checked my spam filter - it's not that!

 

Many thanks for your advice in advance.

Link to comment
Share on other sites

The only thing you can do, to accurately validate an e-mail as existing, is to contact the mail-server. Note that this will be a slow process, and add a noticeable amount of time to your processing. So I don't recommend doing it, unless it's vital that you always send e-mails to an existing e-mail address.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.