rich_traff Posted October 28, 2010 Share Posted October 28, 2010 Hi, I've put together a callback request form that emails my client when someone fills it out. the form is as follows <form method="post" action="php/callbackform.php"> Name: <input name="name" type="text" /><br /> Phone number: <input name="phone" type="text" /><br /> no: <input type="checkbox" name="no" value="This customer does not want their information to be used for marketing purposes" /><br /> <input type="submit" /> </form> it posts to this code <?php $name = $_REQUEST['name'] ; $phone = $_REQUEST['phone'] ; $optout = $_REQUEST['no'] ; $message = $phone . " " . $optout; mail( "[email protected]", "Call back form request", $message, "From: $name" ); header( "Location: http://www.example.com/index.php" ); ?> The problem is that when the email is received, the email 'from' field shows my servers default email address. So if someone called bob filled out the form the resulting email would show as; From: bob<[email protected]> My client doesn't want to add an email box to use as the from address so is there anyway i can hide my address being included in the email header? thanks Richard Quote Link to comment https://forums.phpfreaks.com/topic/217097-can-i-hide-my-address-using-mail-function/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2010 Share Posted October 28, 2010 Yes, don't send an email from your mail server. More seriously, why is this a problem? An alternative would be to send the email directly to the client's email account by him giving you his password to his email account so that you can use SMTP Authentication and send the email directly from the php script to the receiving/client's mail server. Quote Link to comment https://forums.phpfreaks.com/topic/217097-can-i-hide-my-address-using-mail-function/#findComment-1127562 Share on other sites More sharing options...
rich_traff Posted October 28, 2010 Author Share Posted October 28, 2010 More seriously, why is this a problem? Well mainly in this instance because i am building this as a freelancer for an agency, but still hosting on my server. The agency wouldn't want the client to trace direct back to me... An alternative would be to send the email directly to the client's email account by him giving you his password to his email account so that you can use SMTP Authentication and send the email directly from the php script to the receiving/client's mail server. How would i go about this? Im setting them up a new email to handle these enquires so will have the password... Quote Link to comment https://forums.phpfreaks.com/topic/217097-can-i-hide-my-address-using-mail-function/#findComment-1127621 Share on other sites More sharing options...
PFMaBiSmAd Posted October 28, 2010 Share Posted October 28, 2010 You would either write your own script to open a socket connection to the destination mail server and exchange SMTP commends with it, including the SMTP Authorization command, or you would use one of the existing php mailer classes to do this for you. By using SMTP Authorization, the php script 'looks' like an authenticated email client (i.e. outlook) and you can send an email directly to the email account that you have authenticated against, in the same way you would use outlook to send yourself an email to your own inbox. The phpmailer and swiftmailer are two of the more popular php mailer classes - http://phpmailer.worxware.com/ and http://swiftmailer.org/ Quote Link to comment https://forums.phpfreaks.com/topic/217097-can-i-hide-my-address-using-mail-function/#findComment-1127625 Share on other sites More sharing options...
rich_traff Posted October 29, 2010 Author Share Posted October 29, 2010 ok. thanks for those, il take a look Quote Link to comment https://forums.phpfreaks.com/topic/217097-can-i-hide-my-address-using-mail-function/#findComment-1127936 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.