harmanUK Posted November 14, 2008 Share Posted November 14, 2008 Hello, I have been trying to create a simple PHP e-mail form, the code i have at the moment is: <?php { $to = "myemail@gmail.com"; $company = "Matrix Electronics LTD"; $subject = "New Order Notification"; $thanks = "New Order Notification"; $headerclient = "Testing"; $name = $_POST['name']; $email = $_POST['e-mail']; $item1 = $_POST['item1']; $item2 = $_POST['item2']; $item3 = $_POST['item3']; $body = "You have a new order\n Name: <br>$name</br>\n E-mail $email\n Item 1: $item1\n Item 2: $item2\n Item 3: $item3"; $bodyclient = "Thank you for your order <br>$name</br>\n\n You have ordered:\n Item 1: $item1\n Item 2: $item2\n Item 3: $item3\n Thank you for shopping at $company !"; echo "Thank you $name_field, your order has been received at $company! You will receive a confirmation e-mail to $email shortly. "; mail($to, $subject, $body, $headerclient); mail($email, $thanks, $bodyclient, $headerclient); } ?> It works and sends the e-mail's but how to i define who it is from, at the moment when i receive the e-mail its from steadyne@srv2.thewebhostserver.com. How can i change that to the company name? Thanks, Terry Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/ Share on other sites More sharing options...
genericnumber1 Posted November 14, 2008 Share Posted November 14, 2008 Add a From: header based on the standard formats... From: email@domain.com From: Your Name <email@domain.com> Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690500 Share on other sites More sharing options...
harmanUK Posted November 14, 2008 Author Share Posted November 14, 2008 Thanks for your quick reply, can you explain, I only just started learning PHP today trying to get a head start before we start it in class. I'm not 100% sure what a header is. Any chance of a line or two of example code? -Terry Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690503 Share on other sites More sharing options...
genericnumber1 Posted November 14, 2008 Share Posted November 14, 2008 Well when you send an email you have to specify certain headers, which is basically just a email form of a file's metadata... you mistakenly set yours to "testing" which is why I'm surprised it didn't get blocked as spam. Try changing the value of your header variable from "testing" to whatever form matches what you want from my last post. Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690507 Share on other sites More sharing options...
harmanUK Posted November 14, 2008 Author Share Posted November 14, 2008 Thanks again for your quick reply, i have tried this and i dont think im doing something right, its appearing in the body of the message? I have included a screenshot of the e-mail, with the red arrow pointing to what i want to be able to change. http://img99.imageshack.us/my.php?image=helpps6.jpg -Terry Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690511 Share on other sites More sharing options...
DeanWhitehouse Posted November 15, 2008 Share Posted November 15, 2008 http://uk.php.net/manual/ This website should be your number one website to check how to use all php functions. This is what is meant about headers. http://uk.php.net/manual/en/function.mail.php Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690527 Share on other sites More sharing options...
harmanUK Posted November 15, 2008 Author Share Posted November 15, 2008 Thanks, had a look on that site, geat stuff, what i was doing wrong was i had: $headerclient = "noreply@site.co.uk"; When it sould be: $headerclient = "From: noreply@site.co.uk"; Thanks all, solved ! Quote Link to comment https://forums.phpfreaks.com/topic/132771-solved-php-e-mail-form/#findComment-690535 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.