Jump to content

Recommended Posts

I have created a simple contact form, uploaded it to my server, tested it out and get the message that the email has been sent but it never arrives in my email inbox, probabaly really simple.

 

This is the code for the contactsent.php

<?php
$name=$_POST['name'];
$email=$_POST['email'];
$message=$_POST['message'];
$to="myemailaddress.com";
$message="Name: $name n E-mail: $email n Comments: $comments n";
if(mail($to,"Contact from Pure.Salon contact form",$message,"From: $emailn")) {
echo "Thank you, your email has been sent.";
} else {
echo "Sorry but there is an error. Try again please.";
}
?>

Link to comment
https://forums.phpfreaks.com/topic/53465-simple-contact-form-question/
Share on other sites

<?php
$to      = "somebody@example.com";
$message = "Name: {$_POST['name']}\nE-mail: {$_POST['email']}\nComments: {$comments}\n"; // note that $comments is not initialized
if(mail($to, "Contact from Pure.Salong contact form", $message, "From: {$_POST['email']}"))
{
echo "Thank you,your email has been sent.";
}
else {
echo "Sorry but ere is an error. Try again please.";
}
?>

 

Are you doing this on localhost or a remote server?

For the Mail functions to be available' date=' PHP must have access to the sendmail binary on your system during compile time.[/quote']

Chances are that you haven't got any sendmail binary - I haven't got that either on my localhost.

 

About the code... why do you redeclare all the values? You can use arrays in strings...

Example 1074. Sending mail with an additional command line parameter.

 

The additional_parameters parameter can be used to pass an additional parameter to the program configured to use when sending mail using the sendmail_path.

<?php

mail('nobody@example.com', 'the subject', 'the message', null,

  '-fwebmaster@example.com');

?>

 

Have you tried the -f parameter ??? Some hosts require that for mail to be sent.

Thanks for the code but again this still does not work. The thing I cant work out is that I have the original code working on another website with the same hosting company and that works fine, but it wont work for this website.

 

Guess you have to talk with your host then...

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.