简体   繁体   English

如何使用php,Windows 7,WAMP服务器向自己发送电子邮件? 需要简单的解决方案

[英]How to send myself an email with php, Windows 7, WAMP server? need SIMPLE solution

I have spent the last 15 hours 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. 在过去的15个小时中,我尝试了一种简单,免费的方法,即在html页面上填写表格时,通过php脚本发送简单的文本电子邮件。 I don't care how it looks, as these emails are only going to be sent to me (at most 15 a day). 我不在乎它的外观,因为这些电子邮件只会发送给我(每天最多15封)。 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 无法通过“ localhost”端口25连接到邮件服务器,请验证php.ini中的“ SMTP”和“ smtp_port”设置

What i have tried: Playing around with the pear mail extension and using smtp.gmail.com Downloading countless smtp mail server applications. 我尝试过的方法:尝试使用pear邮件扩展名并使用smtp.gmail.com下载无数的smtp邮件服务器应用程序。 Using my ISP smtp and port 25: smtp-server.wi.rr.com. 使用我的ISP SMTP和端口25:smtp-server.wi.rr.com。 Using PHPMailer. 使用PHPMailer。 Using the windows SMTP server. 使用Windows SMTP服务器。

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. 有人请给我一个简单的解决方法,所以我再也不会看PHP邮件了。

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!). 如果所有其他方法均失败,请尝试从邮件客户端发送邮件(或尝试使用Telnet!)。 If this succeeds, than you're doing something wrong in the PHP configuration, or the way you send the e-mail. 如果成功,则说明您在PHP配置或发送电子邮件的方式上做错了什么。 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. 您自己的ISP应该可以正常工作。 Remember that most ISP's don't require you to enter a password. 请记住,大多数ISP都不要求您输入密码。 Only the smtp server will suffice in that case. 在这种情况下,仅smtp服务器就足够了。

Folks. 民间。 After many hours of trying I found that: You don't need additional tools like mailservers or pear additions. 经过数小时的尝试,我发现:您不需要其他工具,例如邮件服务器或添加的pear。 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. 要使邮件功能在localhost上运行,您需要做的就是更改php.ini文件。 I just checked my outlook account settings and copied those to the php.ini file. 我只是检查了我的Outlook帐户设置并将其复制到php.ini文件中。 So SMTP server, port, username and password. 因此,SMTP服务器,端口,用户名和密码。

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 因此,如果php.ini文件包含例如smtp.ziggo.nl,请确保标头包含:发件人: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 (eg z_local) and set the headers accordingly. 因此,为了在本地主机和远程主机上都制作通用代码,我检查了仅本地文件(例如z_local)的存在,并相应地设置了标头。 If the local file does not exist I must be on the remote ISP and choose the header "From: info@remotesite.com" 如果本地文件不存在,则必须位于远程ISP上,然后选择标题“发件人:info@remotesite.com”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM