Contact Form to email
Posted: Sat Oct 01, 2011 11:43 pm
Hello all. I am a new member to this forum and also new to php. Hopefully this community of programers can help me with my basic needs.
When I submit my form, I recieve this error:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\formTest.php on line 23
I get this ^ warning because of this line of code: ini_set ("sendmail_from","myemailaddress@yahoo.com");
Ive read through other forums about my php.ini file and I don't know if i should change any of these defaults. Currently I am testing on localhost but when I get everything running I will put it on my websites server. My question is, how can I get this to send the email through localhost first, and then what setting need to be changed when I decide to put it on a server?
Thanks for any help possible.
My php.ini for the mail()function is this:
[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
Just for the heck of it, heres all my php code. its only 30 lines or so.
<?php
if (array_key_exists('send', $_POST)) {
// mail processing script
$to = 'myemailaddress@yahoo.com';
$subject = 'Feedback from form';
// Process the $_POST variables
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
// Build the message
$message = "Name: $name\r\n\r\n";
$message .= "Email: $email\r\n\r\n";
$message .= "Comments: $comments";
// Limit the line length
$message = wordwrap($message, 150);
// Send it
$mailSent = mail($to, $subject, $message);
ini_set ("sendmail_from","myemailaddress@yahoo.com");
}
?>
When I submit my form, I recieve this error:
Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in C:\xampp\htdocs\formTest.php on line 23
I get this ^ warning because of this line of code: ini_set ("sendmail_from","myemailaddress@yahoo.com");
Ive read through other forums about my php.ini file and I don't know if i should change any of these defaults. Currently I am testing on localhost but when I get everything running I will put it on my websites server. My question is, how can I get this to send the email through localhost first, and then what setting need to be changed when I decide to put it on a server?
Thanks for any help possible.
My php.ini for the mail()function is this:
[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
Just for the heck of it, heres all my php code. its only 30 lines or so.
<?php
if (array_key_exists('send', $_POST)) {
// mail processing script
$to = 'myemailaddress@yahoo.com';
$subject = 'Feedback from form';
// Process the $_POST variables
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
// Build the message
$message = "Name: $name\r\n\r\n";
$message .= "Email: $email\r\n\r\n";
$message .= "Comments: $comments";
// Limit the line length
$message = wordwrap($message, 150);
// Send it
$mailSent = mail($to, $subject, $message);
ini_set ("sendmail_from","myemailaddress@yahoo.com");
}
?>