On my site im working on I will be having some forms that will send mail to me once the forms have been filled out. Im looking for a mail script or something that can do these things...
1) Send mail to me once visitor has filled out the form
2) Will add the persons email address to a list (db or flatfile, db prefered)
3) Validate email address with a "click here to verify" link in it, perhaps.
4) Will allow me to send text and HTML mail
I think thats it. Any ideas?
Thanks for the help
Last edited by wayne3503; 09-05-2007 at 04:48 PM..
3) When you add the persons email address to the database, also add a random integer to a second column, generated using mt_rand. Include this integer as a variable tagged on to the end of a verify link in your email that you send. For example, www.domain.com/verify.php?user=12345678.
Have verify.php check the database for this user and if found, either mark the user as "verified" in a third column, or move the user to another table (neater, imo).
For extra security, include dummy numbers at the start and end of the integer that you email out, and use substr
to extract just the part you need to check against the database.
I have been trying to use mail() in my web page. For development I am using localhost on an XP platform. I cannot send an email to myself. mail always returns false. Looking through the documentation at php.net I read that "For the Mail functions to be available, PHP must have access to the sendmail binary on your system during compile time." If I didn't compile php on my own machine does that mean that I can't test the mail function until it is on the production server?
My php.ini shows smtp='localhost'
PHP Code:
$email = $_POST['toadd'] ; $subject = $_POST['subject'] ; $headers='From:'.$_POST['fromadd']; $message=wordwrap($_POST['mailmsg'], 70); $message=str_replace('\n.', '\n..', $message); if (mail("myaddress@yahoo.com", $subject, $message, $headers )){ echo "Thank you for using our mail form"; }else{ echo "It didn't work."; }
Do I have to do anything else with the php.ini?
Thanks.
__________________
Scott Stewart
Always happy to learn from pros.
I have a sendmail.dll in my c:windows/system32 folder. I have also checked to make sure that the folder is in the path environment variable and in the user path variable.
__________________
Scott Stewart
Always happy to learn from pros.
What executable do I need? According to the php documentation on mail() all windows needs is "localhost" as the smtp. But it also says that sendmail has to be present at compile time. Whats up with that?
__________________
Scott Stewart
Always happy to learn from pros.
Slow down. Even if you setup a mail server on your local development system, unless it is a properly configured public mail server with proper DNS records pointing to it, you will not be able to send an email to any other mail system. The receiving mail servers simply won't recognize your mail server as a valid server. If you want to go through the trouble of setting up an SMTP mail server, there are several open source/free ones available. You would be able to send an email locally to yourself on your local mail server. I just don't think that this amount of effort will get you very far toward developing and testing your scripts.
Secondly, PHP on Windows can only use an SMTP mail server. To do this you need to set the SMTP = and smtp_port = settings to point to the SMTP server that you intend to use. You can set these in php.ini, a .htaccess file, or at runtime using ini_set(...) statements in your code.
Normally, to allow you to test sending email from code on a development system, you use an SMTP server at your ISP or at the hosting company where you will ultimately run the script at.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
I'm curious about one of wayne's initial questions that went unanswered. #4. Does anyone know how to send an html email using the php mail function?
I have the function all set up and working for text emails, but I'd like to be able to use html rather than simply text in the email body. Placing <html></html> tags on the ends of the body didn't seem to do the trick.
However, to send both plain text and HTML bodies at the same time (and let the mail client display the one it is capable of/set for), you need to send a multi-part mime message, with mime boundaries, content type headers... The easiest way to do this is to use one of the existing mailer classes, such as the phpmailer - http://phpmailer.sourceforge.net/
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.
wow alot of stuff happened in here. Thank you all for your posts and also, Im not trying to send both html and text at the same time, i just want the flexability to do either. Maybe what I will do is leave it to the site visitor to choose if they want plain text or html.
Once ScottInTexas hijacked the thread it did get a little off topic.
I took your "and" in item #4 literally, as it is possible to send both types of message bodies at the same time and let the email client display the one that it can or is set for.
__________________
If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.