Re: Mail Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Why not validate the email address before you send. I use something like this to kick back an error that says you put in a bad email address. It won't tell you about a wrong email address, but it will tell you if they forgot to put in the @ sign and stuff.

if  (!preg_match("/^(.+)@[a-zA-Z0-9-]+\.[a-zA-Z0-9.-]+$/si", $data))
{	$email_error = "yes";	}

--
Kevin Murphy
Webmaster: Information and Marketing Services
Western Nevada Community College
www.wncc.edu
775-445-3326


On Sep 26, 2006, at 9:09 AM, php@xxxxxxxxxxxx wrote:

I have an issue with sending email via PHP which may be a configuration problem with either PHP, Apache, or possibly a Sendmail, but I don't know which yet. I figured I'd start here first.

Here's the situation. I have several webpages that send email to users for various reasons. We have our webserver, an intranet webserver, configured to connect to our smtp server which sits on a different box. The script looks like this:

<?PHP
$from = "webmaster@xxxxxxxxxxxx";
$to = "someemail@xxxxxxxxxxxx";
$subject = "Test";
$msg = "This is a test from my site\n\nTimestamp: " . date("r");
$headers = "From:$from\r\n";
if(!mail($to,$subject,$msg,$headers)) { die("Unable to send"); }
?>

This works great when it works. Users receive email as expected and when they hit reply it goes back to the webmaster email address. The problem is if the to email address isn't a valid one. When this happens, the mail server bounces the message back to apache@intranet-server instead of webmaster@xxxxxxxxxxxxx

I've tried adding reply-to to the mail headers and that doesn't work either. We tried sending the same failed message using webmin and that worked great, which is why I believe this to be a PHP or Apache problem.

Any ideas?

Thanks,
Robbert

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux