...

View Full Version : Email form From:



PitbullMean
03-11-2009, 12:58 AM
Is there a way to have it so the form puts then senders email in the Heading instead of mine.

Cause I use mozilla thunderbird and when you check the email it puts it as such

Subject: then the subject

To: my email

Date: Date sent.

From: senders email


But my form it puts my email in the from section I have tried many ways to get around it, it either no longer sends the form email or it sends it by saying eric@node64.com or something


Any help would be appreciated;


$EmailFrom = "eric@habugfx.com";

// I have tried putting $email; "From: $email"; but nothing works.
$EmailTo = "eric@habugfx.com";
$Subject = "Habu GFX Contact Form";

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

image of what i mean

http://www.eric.dragonethosting.com/screenie.jpg

ninnypants
03-11-2009, 03:14 AM
You just need to require the senders email and pull it out of the post/get data.


$EmailFrom = $_POST['from'];

// I have tried putting $email; "From: $email"; but nothing works.
$EmailTo = "eric@habugfx.com";
$Subject = "Habu GFX Contact Form";

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");

PitbullMean
03-11-2009, 05:01 AM
Nope didnt send the email at all, heres the full php code.



<?php
//DO NOT REMOVE THIS PHP CODE
if (isset($_POST['submit'])) {
$name = $_POST['Name'];
$email = $_POST['Email'];
$message = $_POST['Message'];

if (empty($name))
$err1 = 1;
elseif (empty($email))
$err2 = 1;
elseif (empty($message))
$err3 = 1;
else {
if (!preg_match('/^([a-z0-9])([\w\.\-\+])+([a-z0-9])\@(([\w\-]?)+\.)+([a-z]{2,4})$/i',$email))
$err4 = 1;
else {
$EmailFrom = "eric@dragonethosting.com";
$EmailTo = "eric@habugfx.com";
$Subject = "Habu GFX Contact Form";

// prepare email body text
$Body = "";
$Body .= "Name: ";
$Body .= $name;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $email;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $message;
$Body .= "\n";

// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
}

}
}
?>

PappaJohn
03-11-2009, 07:52 AM
Take a look at example #2: http://us2.php.net/manual/en/function.mail.php

Keep in mind that changing the From header to an email address that is not a valid address at your domain may not be advisable. Your mail server could block it; the recipients mail server could consider it spam. The Reply-To header may be a (less than perfect) alternative.

riwan
03-11-2009, 09:41 AM
it should be this

$EmailFrom = $email

I would say you need to print out $err1, $err2, $err3, $err4, just to be sure its getting to the mail part

abduraooft
03-11-2009, 10:40 AM
Is there a way to have it so the form puts then senders email in the Heading instead of mine.

Cause I use mozilla thunderbird and when you check the email it puts it as such

Subject: then the subject

To: my email

Date: Date sent.

From: senders email
You could use popular php-mailer classes like PHPMailer (http://phpmailer.codeworxtech.com) Or SwiftMailer (http://www.swiftmailer.org/) to reduce the hassles.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum