Forum Moderators: coopster

Message Too Old, No Replies

Problems With mail() Function

Sending mail as 'nobody' -- what does it mean?

         

wonderbread

1:48 am on Jan 30, 2005 (gmt 0)

10+ Year Member



Greetings Everyone,

I've been having some major problems with my host today and I'm hoping for some 3rd party advice to see if they are putting me on.

I have many scripts on my site, a few of which that use the php mail() function to send a confirmation code to users in order to verify their e-mail addresses before they are allowed to be a user on my site.

All of the sudden today, my scripts stopped functioning. They will not send messages out to any e-mail address whose domain is not hosted on the same server as my site. This completely breaks all of my scripts.

My host has told me that they have prevented the server option for 'nobody' to send mails because of supposed spam reasons. They say that this is the reason the messages can’t get sent. If this is true, it seems completely illogical as it will break literally thousands of scripts, even once like phpBB which use the mail() function to send out confirmation e-mails to its users.

Does there explanation for why my mails aren't getting sent make any sense? In all of the php scripts, all of the headers (from, reply) are defined correctly so I'm not sure why it is trying to be sent as 'nobody'.

The server is running Redhat and Apache with PHP 4.3.10.

Below is a test script I created to test…it won’t work unless the $to variable is defined as an address @mydomain.com

<?php
$to = "myname@gmail.com";

$subject = "Test E-mail";
$mailheaders = "From: postman@mydomain.com\n";
$mailheaders .= "Reply-To: postman@mydomain.com \n\n";

$msg = "This is just a test message, please ignore";

//Send that sucker
mail($to, $subject, $msg, $mailheaders);

print("Mail sent to $to");
?>

Any help/incites you could give me would be greatly appreciated.

Thanks!

Nick

jatar_k

8:07 pm on Feb 1, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



did they offer any recommendations?

apache sends mail from php as nobody a lot of the time.

another thing to try is to set the Return-Path as well. I would try playing around with all of the headers to see if something works.

Alexander2005

10:27 pm on Feb 1, 2005 (gmt 0)

10+ Year Member



how about trying this? it is a page i made for a company this year....

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Send mail check script</title>
<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
if (parent.location.href == self.location.href) {
// change the url below to the url of the
// frameset page...
window.location.href = 'index.html';
}
// End -->
</script>
</head>
</head>

<body link="#0000ff" alink="#0000ff" vlink="#0000ff" topmargin="0" leftmargin="0" marginwidth="0" marginheight="0">
<table width=600 height=20>
<tr ><td align=center valign=center> E-mail check script</td></tr >

<b><font face="Arial" size="4" color="#000080"><?php echo($announce)?></font><font face="Arial" size="3"><br>
</font></b>
<br />
<?php
//echo " DEBUG NAME: $first_name $surname " ;
if ( $_POST[state]!= 1 ) {

echo " DEBUG state = $state " ;
echo "<br />There is an error with the Email form<br />" ;

} else {

$flag = 0 ;

// Set the following for each message
$ccText = "whoever@somewhere.com" ;
$bccText = "whoever@somewhere.com" ;
$toText = "whoever@somewhere.com" ;
$subjectText = "this is the subject field" ;
if ( $_POST[first_name] == "" ) {
echo "The First name has to be filled in<br />" ;
$flag = 1 ;
} else {
if ( $_POST[first_name] == "^.+[0-9]+.+" ) {
echo "The First name can NOT cotain numbers<br />" ;
$flag = 1 ;
}
}
if ( $_POST[surname] == "" ) {
echo "The Surname name has to be fill in<br />" ;
$flag = 1 ;
} else {
if ( $_POST[surname] == "^.+[0-9]+.+" )
{
echo "The Surname name can NOT cotain numbers<br />" ;
$flag = 1 ;
}
}

/*
$address = "" ;
*/
if ( $_POST[email_address1] == "" )
{
echo "The E-mail address has to be filled in!<br />" ;
$flag = 1 ;
} else {
//if ( $_POST[email_address1]!= ".+@.+\..+" )
//{
//echo "The E-mail address is not valid!" ;
//$flag = 1 ;
//}
}
//if ( "$_POST[email_address1]"!= "$_POST[mail_address2]" )
//{
// echo "The Second E-mail address does not match the first one!<br />" ;
// $flag = 1 ;
//}
if ( $_POST[mobile_number] == "" && $_POST[phone_number] == "" )
{
echo "You must fill in either Phone number or Mobile Number<br />" ;
$flag = 1 ;
} else {
//if ( $_POST[mobile_number]!= "^[0-9'-()]+" )
//{
//echo "The Mobile Number can contain numbers, hyphens, commas and brackets only<br />" ;
//$flag = 1 ;
//}
//if ( $_POST[phone_number]!= "^[0-9'-()]+" )
//{
//echo "The Phone Number can contain numbers, hyphens, commas and brackets only<br />" ;
//$flag = 1 ;
//}
}

if ($ccText!= "") $ccText="Cc: $ccText <$ccText>" ;
if ($bccText!= "") $bccText="Bcc: $bccText <$bccText>" ;

mail($toText, $subjectText, $msgText,"To: $toText <$toText>\nFrom: $fromText <$fromText>\n$ccText\n.$bccText\nX-Mailer: PHP 4.x\n");

echo "<body bgcolor=#ffffff>" ;
echo "<table width=600 height=250>" ;
echo "<tr ><td align=center valign=center><font size=5>Thank you for sending your request<br />A representitive from the company will be in touch with you!</font><br>" ;
echo "<font size=3>If you are not re-directed, please <a href=\"main_home.html\">click here</a>." ;
echo "</body>" ;

echo "<script language=javascript>" ;
echo "setTimeout('redirect()', 5000000);" ;
echo "" ;
echo "function redirect()" ;
echo "{" ;
echo "window.document.location.href='main_home.html';" ;
echo "}" ;
echo "</script>" ;
}

/* if ($mailformat == "Html") {
mail($toText, $subjectText, $msgText,
"To: $toText <$toText>\n" .
"From: $fromText <$fromText>\n" .$ccText.$bccText.
"MIME-Version: 1.0\n" .
"Content-type: text/html; charset=iso-8859-1");
}
*/

?>

</body>
</html>