How to send myself an email with php, Windows 7, WAMP server? need SIMPLE solution
I have spent the last 15 ho开发者_如何转开发urs trying to figure out a simple, free way to send a simple text email via a php script when a form is filled out on a html page. I don't care how it looks, as these emails are only going to be sent to me (at most 15 a day). I don't need anything except a simple email to me when the form is filled out. I understand everything except I cannot get past:
Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini
What i have tried: Playing around with the pear mail extension and using smtp.gmail.com Downloading countless smtp mail server applications. Using my ISP smtp and port 25: smtp-server.wi.rr.com. Using PHPMailer. Using the windows SMTP server.
Although all of these things should work... I am apparently too dumb to figure it out. I have read every sentence on the subject on the internet and have tried to follow instructions, but each time I try something else, I just run into more problems. Someone PLEASE give me a simple fix to this, so I can never look at PHP mail stuff again.
If you're sure all these settings are correct, you should check your firewall. If all else fails, try sending a mail from a mail client (or make an attempt using Telnet!). If this succeeds, than you're doing something wrong in the PHP configuration, or the way you send the e-mail. If sending fails with other clients too, than the problem lies in the ability to send e-mails from that computer at all.
Your own ISP should work fine. Remember that most ISP's don't require you to enter a password. Only the smtp server will suffice in that case.
Folks. After many hours of trying I found that: You don't need additional tools like mailservers or pear additions. These only provide additional potential security leaks that you have no control or insight over. To get mail function to work on localhost, all you need to do is change the php.ini file. I just checked my outlook account settings and copied those to the php.ini file. So SMTP server, port, username and password.
Now, You may think it does not work but You should know that many mail clients reject emails if the From field has a different domain than the actual domain an email is received from. So if the php.ini file contains for example smtp.ziggo.nl Be sure that the header contains: From: info@ziggo.nl
So for making universal code on both localhost and remote host, I check for the existence of a file that I only have locally (e.g. z_local) and set the headers accordingly. If the local file does not exist I must be on the remote ISP and choose the header "From: info@remotesite.com"
精彩评论