Reputation: 37
I'm currently having issues creating a contact form on my website.
I'm wanting to utilize a contact form on my website that uses a local email server (postfix) to send the mail.
Currently I'm having issues implementing this functionality. Is an SMTP server required to send a filled out contact form to a specific email address?
Example...
<?php
if(isset($_POST['submit'])){
$to = "email_goes_here";
$email = $_POST['email'];
$name = $_POST['name'];
$message = $_POST['message'];
$headers = "From:" . $email;
mail($to,$email,$name,$message);
echo "Mail Sent. Thank you " . $name . ", we will contact you shortly.";
}
?>
Would I need an SMTP server to successfully send this captured data to an email address? (captured data being the data put into the form, stored using the POST method).
If I'm on the right track so far, can anyone point me in the right direction to configuring an SMTP server to work with PHP??
This contact form has been an absolute night mare
Thanks in advanced.
Upvotes: 0
Views: 346
Reputation: 822
Assuming your eMail server is working well and therefore you can receive and send emails with it, the only configuration needed for php to be able to send emails within the localhost is in its php.ini file:
[mail function]
SMTP = localhost
smtp_port = 25
sendmail_path = "/usr/sbin/sendmail -t -i"
The 3 first lines might be already in your standard config, being the 4th one the relevant for you.
Save the file after you modify it and restart the Apache server.
Check that your new configuration is working by typing the following command in a terminal window:
echo testing | mail -s Test [email protected]
Regards
EDIT:
More information about the sendmail command for postfix:
http://www.postfix.org/sendmail.1.html
Upvotes: 0