TapeGun007 Posted July 28, 2009 Share Posted July 28, 2009 Ok, I'm a complete php noob. I'm trying to convert some ASP 3 pages to php. So far so good. I have a form that people fill out and it emails me their information. It does not email me however (used to when everything was hard coded with no variables). I could use some help, after reading a bit on this forum, I already see how I can update this code a bit better. Trying to convert isn't exactly the easiest thing when you're used to a particular way of doing things. <? // Declare your variables if ($_GET["done"]=="true") { $strEmail="First Name: " . $_POST["fFirstName"] . "\n"; $strEmail=$strEmail . "Last Name: " . $_POST["fLastName"] . "\n"; $strEmail=$strEmail . "Time Zone: " . $_POST["fTimeZone"] . "\n"; $strEmail=$strEmail . "Phone: " . $_POST["fPhone"] . "\n"; $strEmail=$strEmail . "Email: " . $_POST["fEmail"] . "\n"; $strEmail=$strEmail . "Fax: " . $_POST["fFax"] . "\n"; $strEmail=$strEmail . "Business Name: " . $_POST["fBusinessName"] . "\n"; $strEmail=$strEmail . "Business Type: " . $_POST["fBizType"] . "\n"; $strEmail=$strEmail . "Good Sold: " . $_POST["fGoodsSold"] . "\n"; $strEmail=$strEmail . "Terminal: " . $_POST["fTerminal"] . "\n"; $strEmail=$strEmail . "Credit Rating: " . $_POST["fCreditRating"] . "\n"; $strEmail=$strEmail . "Checks: " . $_POST["fChecks"] . "\n"; $strEmail=$strEmail . "Gift Cards: " . $_POST["fGiftCards"] . "\n"; $strEmail=$strEmail . "Comments: " . $_POST["fComments"] . "\n"; $to = "[email protected]"; $subject = "Lead from MeirSystems"; $message = wordwrap($strEmail,70); echo $message; $from = "[email protected]"; $headers = "From: $from"; mail($to,$subject,$message,$headers); ?> You can view this form at www.meirsystems.com/applynow.php Thank you for helping! Also, does the mail() function allow me to send in HTML format? Quote Link to comment https://forums.phpfreaks.com/topic/167756-solved-mail-help/ Share on other sites More sharing options...
mmarif4u Posted July 28, 2009 Share Posted July 28, 2009 http://my.php.net/manual/en/function.mail.php If you want to use html, images etc etc... http://pear.php.net/package/Mail_Mime Quote Link to comment https://forums.phpfreaks.com/topic/167756-solved-mail-help/#findComment-884657 Share on other sites More sharing options...
kayess2004 Posted July 28, 2009 Share Posted July 28, 2009 Hi, You can send HTML via mail() using the following in your $headers // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; // Additional headers // $headers .= 'To: YoMama <[email protected]>' . "\r\n"; $headers .= 'Cc: YoPapa <[email protected]>' . "\r\n"; $headers .= 'Bcc: YoBrudda <[email protected]>' . "\r\n"; $headers .= 'From: YoMama <[email protected]>' . "\r\n"; Just create your HTML for the body of the message and pass it to the mail() function. Hope this helps Quote Link to comment https://forums.phpfreaks.com/topic/167756-solved-mail-help/#findComment-884862 Share on other sites More sharing options...
TapeGun007 Posted July 29, 2009 Author Share Posted July 29, 2009 Ok, I just got a chance to go back and play with this, and no luck. What the problem is, is that if I change the mail() to mail($to,$subject,$headers); instead of mail($to,$subject,$message,$headers); It sends me an email just fine. I use the echo commands to see what is in $message, and it comes out just fine. But having that $message in there causes the email not to be sent at all. Can someone help explain what I am doing wrong here? Quote Link to comment https://forums.phpfreaks.com/topic/167756-solved-mail-help/#findComment-886378 Share on other sites More sharing options...
TapeGun007 Posted July 29, 2009 Author Share Posted July 29, 2009 Uh... problem solved... I'm not sure why, but I would never have figured it out if I didn't have an ASP page that I tested on a few weeks ago. I have GoDaddy as my webhost (would I wouldn't recommend to anyone). While testing some email capability in ASP, I noticed I would not received emails if I used "[email protected]" for some reason. It just dawned on me, that I was using that to fill in my form. I tried another email address and it delivers fine. Quote Link to comment https://forums.phpfreaks.com/topic/167756-solved-mail-help/#findComment-886393 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.