CrossY Posted October 25, 2010 Share Posted October 25, 2010 Hello PHPFreaks, I'm sorry about the vague topic title, but allow me to explain: I got a PHP form with some fields, and it sends the input data to me, and a copy to the person that submits it. Only the receiver of the email sees the email it came from as: example.com@webhost-mailserver.com, rather than just "example.com" or "info@example.com". Is there a way to control this, so people dont see the root host? Coding: // send email $headers = "From: \"$naam\" <$email>\n"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl"; $message = " blabla their input etc. "; mail ("$youremail", $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); If you need more of the code let me know, but as far as I can tell this seems to be the part where it can be changed (coming from a PHP-dummy ) Thanks in advance! Dave Quote Link to comment Share on other sites More sharing options...
phpfreak Posted October 25, 2010 Share Posted October 25, 2010 I see that you're not actually using the $headers variable in your mail function. so, $from = "Katralin.nl" isn't actually going to do anything in the headers... Check the http://php.net/mail function and the example it gives you to use the $headers is as follows: <?php $to = 'nobody@example.com'; $subject = 'the subject'; $message = 'hello'; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $message, $headers); ?> Quote Link to comment Share on other sites More sharing options...
phpfreak Posted October 25, 2010 Share Posted October 25, 2010 You may just need to make $from an actual e-mail address and your headers should be fine the way your example was. Quote Link to comment Share on other sites More sharing options...
CrossY Posted October 25, 2010 Author Share Posted October 25, 2010 You may just need to make $from an actual e-mail address and your headers should be fine the way your example was. That worked, thanks! Another question though; I got this now: $youremail = "my.email@gmail.com, $email"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl <info@kartalin.nl>"; $message = "blabla" mail ("$youremail", $subject, $message, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); Though it sends the mail to me, and the person that submitted the form, but its rather ugly reading the mail (To: my.email@gmail.com;submitter@example.com). Is there a way to get either of those into BCC? Ive tried: $youremail = "my.email@gmail.com"; $headers = "Bcc: $email" . "\r\n"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl <info@kartalin.nl>"; $message = "blabla" mail ("$youremail", $subject, $message, $headers, "From: $from\nContent-Type: text/html; charset=iso-8859-1"); But then the form doesnt seem to send anything, or just 1 (to my.email@gmail.com), can't quite recall (tried alot of variables ). Any help is appriciated! Dave Quote Link to comment Share on other sites More sharing options...
tastro Posted October 25, 2010 Share Posted October 25, 2010 why do you add a , between the headers? headers this should be only one string or not? also like this: $youremail = "my.email@gmail.com"; $headers = "Bcc: $email" . "\r\n"; $subject = "Contactformulier Kartalin"; $from = "Kartalin.nl <info@kartalin.nl>"; $message = "blabla" mail ("$youremail", $subject, $message, $headers." "."From: $from\nContent-Type: text/html; charset=iso-8859-1"); if this doesn't work then just use the mail() function twice. Quote Link to comment Share on other sites More sharing options...
CrossY Posted October 26, 2010 Author Share Posted October 26, 2010 if this doesn't work then just use the mail() function twice. Haha, pure genius Thanks! Quote Link to comment 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.