Php Send Mail

liunx

Guest
Here is my dilema.<br /><br />I am new to PHP but trying like crazy to learn it. I use Dreamweaver to make my webpages so it does alot of the php for me. This is very nice, in that I can use this to help me understand PHP.<br /><br />The problem I am having is that I cannot successfully setup a form using php to send the info via email. I have tried to use the two CGI emailers from the CPanel to no avail. I liked the one (cant remember the name) that allows you to setup the format and then it sends the info in a neat TXT file. But after hours of changing parameters I gave up.<br /><br />I have been reading books and trying to make a PHP form email using my 2 PHP books but I cant seem to get it to work. <br /><br />Is it possible to use the mail() with TCH? I think so since I saw the path to the sendmail server in the CPanel.<br /><br />Also I have read the you must set the location of the mail server in the PHP.ini file in-order for this to work using Linux. Is this setup on the TCH servers?<br /><br />In the past I used Frontpage (oh I hate to say that, since I have been trying out the MFZ (MS Free Zone)) extensions as the form handlers but Dreamweaver does not have these, or atleast I dont know about them.<br /><br /><br />If anyone could help me out with this I would greatly appreciate it. I am so new at PHP it seems I stumble at each step in the process until I finally get it to work. <br /><br />Thanks for your help<br /><br />Scott.<!--content-->
Yes the mail function should work fine -- I use it extensively on my sites here at TCH. Here is how it works:<br /><a href="http://www.php.net/manual/en/ref.mail.php" target="_blank">http://www.php.net/manual/en/ref.mail.php</a><br /><br />If you want to paste in here the actual script(s) that are not working for you, I'd be happy to have a look.<!--content-->
Thanks for the link. I was looking at it and I think I need to supply the default location in the mail function, but how do I do that?<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><html><br /><?PHP<br />$mail_to = "[email protected]";<br />$mail_subject = "Hi There";<br />$mail_body = "We'll have a time PHPing";<br />$mail_body .= "7 pm friday night";<br />if(mail(mail_to, $mail_subject, $mail_body))<br />    echo "Successfully send the email?\"$mail_subject\" to $mail_to.";<br />else echo "Failed to send the email \"$mail_subject\"."<br /><br />?><br /><br /></html><!--c2--></div><!--ec2--><br />As you can tell this is just a test script to see if I can get it to work. My thinking was to get this working first before I tackled the forms. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /> Basically all it does is send an email when it is run. <br /><br />Thanks for your help MatMan<br /><br />Scott<!--content-->
<!--QuoteBegin-MRwisdom12+May 2 2003, 04:30 PM--><div class='quotetop'>QUOTE(MRwisdom12 @ May 2 2003, 04:30 PM)</div><div class='quotemain'><!--QuoteEBegin-->I am new to PHP but trying like crazy to learn it.<!--QuoteEnd--></div><!--QuoteEEnd--><br /> Thats about were I am with it. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/rolleyes.gif" style="vertical-align:middle" emoid=":rolleyes:" border="0" alt="rolleyes.gif" /> <br /><br />Here's a tip: Go to your local book store/library and try to find "SAMS Teach Yourself PHP in 24 Hours". It is a very easy to read book that can teach you a lot in a short amount of time. <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
I looked at that book, but I put it back for the beginners PHP 4 book by Wrox. Will go to morrow and check it out again. <br /><br />Does it explain sending email in forms and connecting to Databases?<!--content-->
If this is the actual line in your script:<br /><!--quoteo--><div class='quotetop'>QUOTE</div><div class='quotemain'><!--quotec-->if(mail(mail_to, $mail_subject, $mail_body))<!--QuoteEnd--></div><!--QuoteEEnd--><br /><br />It looks like you left out a "$" on your mail_to variable.<br /><br />That will DEFINTITELY not work! <img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><br /><br />Oh, and the WROX book is the best. Actually, theirs usually are.<!--content-->
<!--QuoteBegin-MRwisdom12+May 2 2003, 09:44 PM--><div class='quotetop'>QUOTE(MRwisdom12 @ May 2 2003, 09:44 PM)</div><div class='quotemain'><!--QuoteEBegin-->Does it explain sending email in forms and connecting to Databases?<!--QuoteEnd--></div><!--QuoteEEnd--><br /> I'm only on hour 7 but I'll check in the Table of contents...<br /><br />...<br /><br /><br />......<br /><br />Ok, Hour 9 - Working with Forms, Hour 12 - Database Integration: SQL. I haven't read them yet so I can't ell you how useful they are to your purpose, but check it out.<!--content-->
AHHH!!!!! Dude. Thanks so much for the help. That worked. I guess I was looking at the code so long that I was "seeing" the $ infront of the variable when it wasn't there.<br /><br /><br />Maybe I should get a book on paying attention to detail..<br /><br /><img src="http://www.totalchoicehosting.com/forums/style_emoticons/default/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" /><!--content-->
Is there a way to change the from name? When I send the email it comes into my email address from <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e --><!--content-->
You can specify the FROM:, and many other things in the headers. The user comments on <a href="http://www.php.net/manual/en/ref.mail.php" target="_blank">this link</a> have a lot of examples. I've found them useful.<!--content-->
I hate WROX books. And WROX is also going out of business and not supporting their books.<br /><br />I have Professional PHP Programming. I emailed them to get the code listings, and received return email that they weren't supporting anything anymore as they were no longer going to be in business.<br /><br />--Beth<!--content-->
Wow, I'm disappointed to hear that. For the last four years or so they've been publishing the best programming books on the planet IMHO.<!--content-->
I saw that book at Banes and Nobles bethohio3. (Professional PHP programming). I leafed through it at the store for about 15 minutes, and first of all it was over my head in php programming, but I did feel like that particular book was as "neat" as the beginning PHP 4 book that I have. It seemed to jump all over the place. That is of course IMHO.<br /><br />I do like the other Wrox books as well.<!--content-->
 
Top