PDA

View Full Version : FormMail settings



AlanGNW
09-17-2007, 09:24 AM
I´m using the FormMail script from Matts Script Archive

http://www.scriptarchive.com/formmail.html

What I´m not understanding is how to make it appear that the form appears to be sent from the domain to which it relates rather than from the server address? Anyone know?

sdasevne
09-18-2007, 05:38 PM
I'm using Tectite's form mailer (tectite.com) and have the same problem. I then tried it on another hosting service, and it correctly picks up the "from" name from the form and puts this as the "from" name in the email. But on HostMonster's servers, this does not work. I assume it's something unique to HostMonster.

sjlplat
09-18-2007, 06:28 PM
I've found that you must use an Envelope From header, and you must create the email address being used. I had problems getting a form mailer to work this week, and discovered that once I created the email address, it worked fine. Here is the code I used in my newest php form mailer. Works flawlessly:



$boundary = "\\\\\";
$email = $_REQUEST['email'];
$subject = "Form Mailer Subject";

$headers = "From: Sender Name <no_reply@yourdomain.com>\n";
$headers .= "Return-Path: no_reply@yourdomain.com\n";
$headers .= "Envelope-from: no_reply@yourdomain.com\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";

$msg = "This is a multi-part message in MIME format.\n\n";
$msg .= "--$boundary\n";
$msg .= "Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes\n";
$msg .= "Content-Transfer-Encoding: 7bit\n\n";
$msg .= "Message Goes Here\n";

mail($email, $subject, $msg, $headers);

AlanGNW
09-19-2007, 06:58 AM
I´m using the prerl script?

sjlplat
09-19-2007, 07:27 AM
Headers are headers. If you use the same format I posted, it will work. It just needs to be written in Perl if you elect to go that route. ;)

SiriusB
09-20-2007, 06:12 PM
I've found that you must use an Envelope From header, and you must create the email address being used. I had problems getting a form mailer to work this week, and discovered that once I created the email address, it worked fine. Here is the code I used in my newest php form mailer. Works flawlessly:



$boundary = "\\\\\";
$email = $_REQUEST['email'];
$subject = "Form Mailer Subject";

$headers = "From: Sender Name <no_reply@yourdomain.com>\n";
$headers .= "Return-Path: no_reply@yourdomain.com\n";
$headers .= "Envelope-from: no_reply@yourdomain.com\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"$boundary\"\n";

$msg = "This is a multi-part message in MIME format.\n\n";
$msg .= "--$boundary\n";
$msg .= "Content-Type: text/plain; charset=utf-8; format=flowed; delsp=yes\n";
$msg .= "Content-Transfer-Encoding: 7bit\n\n";
$msg .= "Message Goes Here\n";

mail($email, $subject, $msg, $headers);


Could that code just be whacked into a function and called as needed?

Finally got a form to email me today after much battling and using sitewizards auto generated php form. Your code looks much cleaner [and compact]. Although I haven't had a proper look at the sitewizard code yet.

sjlplat
09-21-2007, 08:07 AM
That's actually the meat of the code. Add it to an if-then-else statement, call it with a form POST, edit the variables, and you're in business.

SiriusB
09-24-2007, 04:22 PM
I have used your code and I am pleased to say it works.

Thanks buddy :)

sjlplat
09-24-2007, 06:27 PM
I have used your code and I am pleased to say it works.

Thanks buddy :)

Good to hear. :)