View Full Version : contact form processor help
andrewjs18
10-23-2011, 04:50 PM
Hi there, I'm hoping someone can help me adjust my form processor so that when the server sends out emails, it doesn't send them out through "username@host107.hostmonster.com". From what I'm reading through the host monster support documents (https://my.hostmonster.com/cgi/help/206), it can be accomplished by modifying the "from" address. However, my php knowledge is limited and removing the parenthesis around the "address from" field breaks the script. Here's my form.php script:
<?php
$name = $_POST["name"];
$email = $_POST["email"];
$problem = $_POST["problem"];
$comments = $_POST["comments"];
$address_to = "removed for security purposes";
$address_from = "removed for security purposes";
$email_subject_line = $name . "'s form";
$email_text = "Name? " . $name .
"\nEmail? " . $email .
"\nProblem? " . $problem .
"\nComments? " . $comments;
mail($address_to, $email_subject_line, $email_text, $address_from);
header ('Location: http://www.yoursite.com);
exit ();
?>
I hope someone is able to lend a hand!
SteveS
10-23-2011, 06:51 PM
This should work.
$emailBody = "This is the body of the email.";
$to = "sample@domain.com" . ", " . $_POST['email1'] . ", " . $_POST['email2'];
$subject = "This is the subject.";
$headers = "From: yourname@yourdomain.com\r\n" . "X-Mailer: php";
$userMes = "";
if (!mail($to, $subject, $emailBody, $headers))
{
$userMes .= "<p><b>WARNING - There was an error sending email.</b></p>";
}
yourname@yourdomain.com must be a valid email. It does not need to have an actual mailbox, a valid forwarder is acceptable. If the email is not valid, it will be sent from "username@host107.hostmonster.com".
andrewjs18
10-23-2011, 10:12 PM
This should work.
$emailBody = "This is the body of the email.";
$to = "sample@domain.com" . ", " . $_POST['email1'] . ", " . $_POST['email2'];
$subject = "This is the subject.";
$headers = "From: yourname@yourdomain.com\r\n" . "X-Mailer: php";
$userMes = "";
if (!mail($to, $subject, $emailBody, $headers))
{
$userMes .= "<p><b>WARNING - There was an error sending email.</b></p>";
}
yourname@yourdomain.com must be a valid email. It does not need to have an actual mailbox, a valid forwarder is acceptable. If the email is not valid, it will be sent from "username@host107.hostmonster.com".
does that replace my entire form or does it just replace a portion of it? if it just replaces a portion of it, which portion would that be?
SteveS
10-24-2011, 08:19 AM
does that replace my entire form or does it just replace a portion of it? if it just replaces a portion of it, which portion would that be?
Just change variable $address_from
from:
$address_from = "removed for security purposes";
To:
$address_from = "From: removed for security purposes\r\n" . "X-Mailer: php";
You need to have "From: " before your from address.
andrewjs18
10-24-2011, 04:20 PM
Just change variable $address_from
from:
$address_from = "removed for security purposes";
To:
$address_from = "From: removed for security purposes\r\n" . "X-Mailer: php";
You need to have "From: " before your from address.
that worked perfectly. thanks a bunch!
now I need to modify my contact page to include some anti-spam measures. I suppose I should start a new discussions on that, correct?
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.