I’m running a web server using XAMPP. I have using a web form to send emails using PHP scripting. I was wondering, can some tell me why i’m getting this error?
Warning: mail() [function.mail]: “sendmail_from” not set in php.ini or custom “From:” header missing in C:\xampp\htdocs\format.php on line 24
Here is my php.ini code, with the relevant part provided:
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = postmaster@localhost
Here is also my PHP script, just to show you what i coded (I can’t see anything wrong with line 24 by the way).
<?php
$to = 'lnation@gmail.com';
$subject = 'This is from your company';
$name = $_POST['name'];
$email = $_POST['email'];
$message = $_POST['message'];
$message = <<<EMAIL
Hi! My name is $email
$message
From $name
Oh ya, my email is $email
EMAIL;
$header = '$email';
if($_POST){
mail($to, $subject, $message, $header);
$feedback = 'Thanks for the email';
}
?>
Any suggestions will be appreciated.
Uncomment the sendmail_from setting in the ini file:
sendmail_from = postmaster@localhost
(remove the semicolon from the beginning). You might also change the postmaster@localhost to something you’d actually want people to see as a sender