PHP form data via email

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
aaron72
Forum Newbie
Posts: 2
Joined: Sun Jun 28, 2009 12:44 pm

PHP form data via email

Post by aaron72 »

<?php

$email = "First Name:\t$_POST[fname]\n";
$email .= "Last Name:\t$_POST[lname]\n";
$email .= "Address 1:\t$_POST[add1]\n";
$email .= "Address 2:\t$_POST[add2]\n";
$email .= "City:\t$_POST[city]\n";
$email .= "State:\t$_POST[state]\n";
$email .= "Zip:\t$_POST[zip]\n";
$email .= "Email-id:\t$_POST[eid]\n";
$email .= "Phone:\t$_POST[phone]\n";

$destinatar = "info@xxx.com";
$subiect = "Resume of fname";

$detalii = "From: eid\n";
$detalii .= "Reply-To: $_POST[email]\n\n";

$sent =mail($destinatar, $subiect, $email, $detalii);

if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: PHP form data via email

Post by a94060 »

what is this for? Is there a question that i just cannot see? also wap code in php tags
aaron72
Forum Newbie
Posts: 2
Joined: Sun Jun 28, 2009 12:44 pm

Re: PHP form data via email

Post by aaron72 »

There is an error on this code. I am getting message "We encountered an error sending your mail" trying to figure out why Send is failing?

a94060 wrote:what is this for? Is there a question that i just cannot see? also wap code in php tags
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Re: PHP form data via email

Post by a94060 »

Try echoing $destinatar, $subiect, $email, $detalii . See if you are getting the proper values for each. If you are, the problem may lie in the host not allowing you to send emails.
Post Reply