Jump to content

$from contact form problem

Recommended Posts


Well I'm quite new to PHP (maybe you'll see it in my Q), but I do know some bits and pieces.
Well I've come to 2 or 3 probs on my way to creating my contact form.

I have a form on my website and it's working great, but my mails are sent to my gmail acc and I would

love to know if there's a way to specify the sender in my $from line? Cause now my first lines of PHP looks like this:


// email address that will be showned as a sender
$from = 'New mail from the website <newmail@mywebsitename.eu>';

// email address where the mail should be send to
$sendTo = 'mywebsitesname.eu <mypersonalmail@gmail.com>';

// subject of the email
$subject = 'New message from my mywebsitename.eu site';

And the thing that I would like to do is to change $from line to something like:
$from = $_POST['email'];
So that when I would get the mail to my gmail acc it would be showned as it is from the sender and I would be able to reply to him from one click and not to copy paste his email from my form to new message and then prob copy paste the content of his msg to my reply msg etc... 
Now I know this is a bit ''so-so'' cause I would be faking or spoofing the senders mail, but I'm sure there's a solution. Or at least if that's not possible, to create some sort of code that would prepare my reply_to mail with one click.

Hope I didn't wrote to much of stuff with to many words, but I'm a bit of a chatty fella :D.


Edited by microlarva
Link to post
Share on other sites

It's probably better to use reply-to only, some services will block email if the from address isn't associated with your server.  For example, gmail might block a mail if your server claims that the email is from some other gmail user when gmail knows that your server is not gmail.

  • Like 1
Link to post
Share on other sites

Join the conversation

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

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

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