Jump to content

Securing form to mail script


greens85

Recommended Posts

Hi all,

 

I have a form to mail script that works just fine, the problem is I have no idea where to start in order to make it secure. I know that people can inject headers into the script to spam email accounts.

 

What do I need to add to the code in order to stop this happening and gettin me barred from my host.

 

This is the php code I'm using:

 

<?php
ini_set("sendmail_from", "[email protected]");
$to = "[email protected]";
$subject = "Customer Enquiry";
$name = $_POST ['name'];
$email = $_POST['email'];
$company = $_POST['company'];
$telephone = $_POST['telephone'];
$comments = $_POST['comments'];
$reference = $_POST['reference'];
'[email protected]';

	$headers = 
		"$name\n" .
		"$email\n" .
		"$company\n" .
		"$telephone\n" .
		"$comments\n" .
		"$reference\n" ;

$sent = mail($to, $subject, $headers);

?>

 

The following lines i was told to add by the host:

 

ini_set("sendmail_from", "[email protected]");
'[email protected]';

Link to comment
https://forums.phpfreaks.com/topic/144692-securing-form-to-mail-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.