mojito Posted June 23, 2006 Share Posted June 23, 2006 Hi GuysCurrently I have a contact form on a server which sends a message to the website owner, a simple contact form. I would like the from field to contain the email from the form which the user submits.I have [code]mail("[email protected]", "bit of text", $message2, "From: \"$name\" <$email>\$email") or die(" \n There was some error sending the mail please contact me via email directly [email protected] , sorry for the inconvienience.");[/code]this works but the from field must be being overidden from the server as it puts its own server stamp in there.Am i using mail(); wrong?I just saw this on php siteIf you try to set "From:" e-mail header value under Windows when it is already defined in php.ini "sendmail_from" value, this will doesn't work. If you still want to customize this value, then you must use another option like XPertMailer ( [a href=\"http://www.xpertmailer.com/\" target=\"_blank\"]http://www.xpertmailer.com/[/a] ) to send the e-mail directly to the client SMTP server or use a relay SMTP server with authentification option. Link to comment https://forums.phpfreaks.com/topic/12747-mail-from-webpage-want-to-customise-the-from-field/ Share on other sites More sharing options...
shortj75 Posted June 23, 2006 Share Posted June 23, 2006 try something like thishere is the form[code]form.php<form method=post action=sendemail.php><center><table cellpadding=0 cellspacing=0 class=contacttable><tH class=contacthead><center>Contact</CENTER><TR><TD>From: <input type=text name=email><TR><TD>Subject: <input type=text name=sub size=70><TR><TD>Message:<br /><textarea name=mess cols=80 rows=10></textarea><BR /><input type=submit name=submit value=send></th></tr></td></table></center></form>[/code]and here is the page that sends the email[code]sendemail.php<?php$to = "[email protected]";$sub=$_POST['sub'];$mess = $_POST['mess']; $from="From: $_POST[email]";$mail=mail("$to", "$sub", "$mess", "$from"); if(!$mail){print "<center>Sorry Your E-mail Was Not Sent</center>";}else{print "<center>Your E-mail Was Sent Successfuly</center>"; } ?>[/code]this is the cantact form i have on my site and it works great Link to comment https://forums.phpfreaks.com/topic/12747-mail-from-webpage-want-to-customise-the-from-field/#findComment-48875 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.