Question:

PHP problem, involving textbox info to my email, read below ?

by  |  earlier

0 LIKES UnLike

this code for ppl to send text info from a text box to my email account:

// process the email

if (array_key_exists('send', $_POST)) {

$to = 'me@example.com'; // use your own email address

$subject = 'Feedback from the people';

// process the $_POST variables

$name = $_POST['name'];

$email = $_POST['email'];

$comments = $_POST['comments'];

// build the message

$message = "Name: $name\n\n";

$message .= "Email: $email\n\n";

$message .= "Comments: $comments";

// limit line length to 70 characters

$message = wordwrap($message, 70);

// send it

$mailSent = mail($to, $subject, $message);

}

I keep getting this error: Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\wamp\www\journey\contact_us.php on line 26

how can I fix this?

 Tags:

   Report

1 ANSWERS


  1. Add a "from" value to the mail function call as an additional header. Here's why, directly from the PHP web site:

    "Note: When sending mail, the mail must contain a From header. This can be set with the additional_headers  parameter, or a default can be set in php.ini.

    Failing to do this will result in an error message similar to Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing. The From header sets also Return-Path under Windows."

Question Stats

Latest activity: earlier.
This question has 1 answers.

BECOME A GUIDE

Share your knowledge and help people by answering questions.