Jump to content

can i hide my address using mail function?


rich_traff

Recommended Posts

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( "client@example.com", "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<default@myserver.com>

 

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

Link to comment
Share on other sites

Yes, don't send an email from your mail server.  :D

 

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.

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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/

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.