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 = "[email protected]";
if (!empty($scrubbed['emailAddress'])) {
$from = $scrubbed['emailAddress'];
}
mail('[email protected]','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
https://forums.phpfreaks.com/topic/271607-bizarre-email-problem/
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.

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.