Jump to content

Not receiving email from php form


keefy

Recommended Posts

Hi,

 

Ive got a paid property script on my website, The script works ok on one of my sites, but the site i want it to work on seems to send the form but i never recieve it in my email...

 

The hosting company says:- Thank you for your query

 

This issue is occuring because there is a missing fifth parameter in your mail script. This has always been a requirement of mail scripts on our shared hosting platform but recent updates to our Linux servers (from PHP4 to PHP5) has meant that this is now always required.

 

An example of how to use can be found below:

 

What is the path to Sendmail?

 

/usr/sbin/sendmail -fuser\@domainname.co.uk

 

You need to replace -fuser\@domainname.co.uk with a valid mailbox on your account:

ie -froot\@yourdomain.co.uk

 

You must leave in the -f and make sure there is a \ before the @

 

An example of how to use this is displayed below:

mail($to, $sub, $mess, "From: root@yourdomain.co.uk", "-froot@yourdomain.co.uk");

 

Please note when sending email from a script on your website either the to or from address needs to be a valid email account that is setup, eg root@yourdomain.co.uk

 

 

Ive sent a email to the author of the script and he says - "I have never heard of PHP mail being used like this before!!"

 

 

Below is the script from the property script, Can anyone help me change it so that its compatible to what the hosting company has said...

 

 

<script language="JavaScript" type="text/javascript">
<!-- Begin
var submitcount=0;
function reset() {
document.emailform.name.value="";
document.emailform.email.value="";
document.emailform.address.value="";
}

function checkFields() {                    
if (                                    
(document.emailform.name.value=="") ||
(document.emailform.email.value=="")  ||
(document.emailform.address.value==""))  
  {
  alert("<?php echo GENERAL_FORM_POPUP_ERROR_MESSAGE; ?>");
  return false;
  }
}
//  End --></script>
<?php
 
 if ( $cgi->getValue ( "op" ) == "SendInformationRequest" )
 {
// Contact Form Spam Check for Website URl's which should not be there
$SpamErrorMessage = "<p align=\"center\"><font color=\"red\">Website URLs are not permitted in the request form.</font></b></p>";
if (preg_match("/http/", "" . $cgi->getValue ( "name" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "email" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "telephone" ) . "")) {echo "$SpamErrorMessage"; exit();} 
if (preg_match("/http/", "" . $cgi->getValue ( "address" ) . "")) {echo "$SpamErrorMessage"; exit();} 
 
   $yoursubject = "".EMAIL_SUBJECT." Ref: " . $cgi->getValue ( "propertyref" );
   $emailtext = "
-----------------------------------------------------------------------------
  ".EMAIL_TEXT_TITLE."
-----------------------------------------------------------------------------
".EMAIL_TEXT_BODY."

".EMAIL_PD."
".EMAIL_PROEPRTY_REF."      " . $cgi->getValue ( "propertyref" ) . "
".EMAIL_PROPERTY_ADDRESS."  " . $cgi->getValue ( "propertyaddress" ) . "
".EMAIL_PROPERTY_PRICE."    ".CURRENCY.""  . $cgi->getValue ( "propertyprice" ) . "

".EMAIL_RD."
".EMAIL_NAME."    " . $cgi->getValue ( "name" ) . "
".EMAIL_EMAIL_ADDRESS."   " . $cgi->getValue ( "email" ) . "
".EMAIL_TELEPHONE."   " . $cgi->getValue ( "telephone" ) . "

" . $cgi->getValue ( "address" ) . "

_____________________________________________________________
".EMAIL_FOOTER."www.egypt4property.com/index.php?op=mi&id=" . $cgi->getValue ( "id" ) . "
";

   $yoursubject = stripslashes ( $yoursubject ); 
   $emailtext = stripslashes ( $emailtext );
   @mail ( $cgi->getValue ( "adminemailaddress" ), $yoursubject, $emailtext,
       "From: " . $cgi->getValue ( "email" ) ); 
?>
<br />
<br />
<br />
<p align="center"><?php echo EMAIL_SUCCESS_MESSAGE; ?></p>

 

Thanks for any help

 

Keefy

Link to comment
Share on other sites

Just as your provider states, you need to provide the additional parameter to the mail function:

 

 @mail ( $cgi->getValue ( "adminemailaddress" ), $yoursubject, $emailtext, "From: " . $cgi->getValue ( "email" ), "-fyourmail@yourdomain.whatever" ); 

 

If the author hasn't heard of it before tell him/her to go read the manual:  http://www.php.net/function.mail, example 3.

 

The options that can be provided in this manner are found in the sendmail man page:

 

http://www.sendmail.org/~ca/email/man/sendmail.html (or "man sendmail" from the command line)

 

In particular, the "-f" states:

 

    -fname      Sets the name of the ``from'' person (i.e., the sender of the

                mail).  -f can only be used by ``trusted'' users (normally

                root, daemon, and network) or if the person you are trying to

                become is the same as the person you are.

Link to comment
Share on other sites

Thank you very much hitman6003

 

It now works :)

 

Does the ("adminmailaddress") need removing ? This gets the email address from the database which is the same as the -fyourmail@yourdomain.whatever without the -f

 

@mail ( $cgi->getValue ( "adminemailaddress" ), $yoursubject, $emailtext, "From: " . $cgi->getValue ( "email" ), "-fyourmail@yourdomain.whatever" );

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.