Register Advertise with usHelp Desk Today's Posts Search

Closed Thread
Thread Tools Search this Thread
Unread 31st Jul 2009, 10:21 AM   #1
Active Warrior
 
Join Date: 2009
Location: South Africa
Posts: 66
Thanks: 17
Thanked 1 Time in 1 Post
Default
Please help me with sendmail!
Share on: 
fb share twitter share gplus share more share

Hi all

I hope you can help me. I set up a simple form on my website, only fields for name and e-mail and a send button. I am using Joomla, and I added the folowing code in the source field of an article. (Should it be here or somewhere else?)

Code:
 
<form action="sendmail.php" method="post" name="Form">
<p style="text-align: center">Name&nbsp;&nbsp;&nbsp; <input name="Name" type="text" /></p>
<p style="text-align: center">E-mail&nbsp;&nbsp; <input name="E-mail" type="text" /></p>
<p style="text-align: center"><input type="submit" name="Send" value="Send" /></p>
</form>


Code:
 
<?php
$Name = $_REQUEST['Name'] ;
$E-mail = $_REQUEST['E-mail'] ;
mail( "me@mysite.com", "Feedback Form Results",
$message, "From: $Name" );
header( "Location: http://www.redirecthere.com" );
?>



I made sure sendmail is selected in the global configuration, and the sendmail path is given as /usr/sbin/sendmail.

Now when I enter values and click send on my site I get the following message: "The page cannot be found". The URL of this page is http://www.mysite.com/sendmail.php. What is wrong? I know this is a simple form, but I want to test the sendmail function before I write a more complicated form script.

Thanks
Cruiser is offline  
Unread 1st Sep 2009, 10:58 AM   #2
Advanced Warrior
War Room Member
 
Bruce Hearder's Avatar
 
Join Date: 2004
Location: Perth, Australia.
Posts: 724
Thanks: 6
Thanked 184 Times in 136 Posts
Default
Re: Please help me with sendmail!
Share on: 
fb share twitter share gplus share more share

Hi Cruiser,

The problem (I believe) lies in your sendmail.php file.

I would suggest the following code to replace your sendmail.php file :


<?php
$to_email = "me@mywebsite.com";
$redirectto = "http://www.redirecthere.com";

if (isset($_POST['Send']))
{
$name = strip_tags(trim(stripslashes($_POST["Name"])));
$email = strip_tags(trim(stripslashes($_POST["E-mail"])));
$title = "Feedback Form Results";

$msg = "A new user has just signed up. Their details are as follows:
Name : $name
Email : $email";

$headers = "From: $name <$email>\r\n" .
"Reply-To: $name <$email>\r\n" .
"X-Mailer: PHP/" . phpversion();

mail($to_email, $title, $msg, $headers);
header('Location: '.$redirectto);
exit;
}

?>


I think this should do the job for you

Hope this helps

Bruce
Bruce Hearder is offline  
Closed Thread


Bookmarks

Tags
sendmail


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




All times are GMT -6. The time now is 04:14 PM.