Jump to content

PHP problem with email - help appreciated.


SteveH

Recommended Posts

Hello

 

I have an online form which, when completed, should send me an email with the details of that user,

that is, his name, email address, business, country, and message.

 

When I receive the message in my inbox, however, it looks like this:

 

http://www11.brinkster.com/stevehigham/error.html

 

It does not show the name of the person who completed the form, or his email address. It is also

showing email 'From' as [email protected] when it should show [email protected].

 

To complicate matters, it uses 'education' (in the above link) as the Subject and it does not send

the user a copy of what he has input into the form.

 

What am I doing wrong, please?

 

The code looks like this:

 

<?php

 

//create short variable names

$name=$_POST['name'];

$email=$_POST['email'];

$business=$_POST['business'];

$country=$_POST['country'];

$message=$_POST['message'];

$name=trim($name);

$email=trim($email);

$business=StripSlashes($business);

$country=StripSlashes($country);

$message=StripSlashes($message);

 

/*#########

modify the next line with your own email address

###########*/

 

$toaddress='[email protected]';

 

 

mail("$toaddress","$business","$country","$message","From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n");

//clear the variables

$name='';

$email='';

$business='';

$country='';

$message='';

exit;

 

 

?>

 

 

Thank you.

 

Steve

 

 

Link to comment
https://forums.phpfreaks.com/topic/84672-php-problem-with-email-help-appreciated/
Share on other sites

Steve,

 

Hard code some values in there before you get into the $_POST part.  But, you are going to want to check all that post stuff before just sending it.  Also, I found that Yahoo mail for me was a little buggy, but when I changed the \r\n to just \n that solved a few problems.

 

It looks like you have an extra entry with $country.  This code might work.

 


$subject=$business;
$subject=$country;
$headers=From: $name <$email>\r\nReply-To: $email\r\nReturn-Path: $email\r\nCc: $email\r\n;
$mailsnd=mail("$toaddress","$subject","$message","$headers");

 

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.