简体   繁体   English

使用php5发送邮件

[英]send mail by using php5

i wish to send form data throw mailto() in php, but i got an warning msg that "Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\\xampp\\htdocs\\ 我希望在php中发送表单数据并发送mailto(),但是我收到一条警告消息,提示“警告:mail()[function.mail]:无法在“ localhost”端口25上连接到邮件服务器,请验证您的“ SMTP”并php.ini中的“ smtp_port”设置,或在C:\\ xampp \\ htdocs \\中使用ini_set()

please sugest me that what i have to do for send data to a mail id properly 请向我表示我要正确地将数据发送到邮件ID所要做的事情

Instead of using the raw mail() function, with which you'll have to do everything yourself, it would probably be better to learn how to use a component such as swift mailer . 与其使用原始的mail()函数mail()您必须自己执行所有操作),不如学习如何使用诸如swift mailer的组件,可能会更好。

It might take a bit of time to go through the documentation, but it provides a lot a useful features that you'll be able to re-use accross different projects (like HTML, attached documents, mailling via a remote SMTP server, ...) 可能需要花费一些时间来阅读文档,但是它提供了许多有用的功能,您可以在不同的项目中重复使用这些功能(例如HTML,附加文档,通过远程SMTP服务器的邮件,.. )


Note : there are several great mail components available -- swift is one of them, which is sued in Frameworks such as Symfony, and, as such, should be well-supported. 注意:有几个很棒的邮件组件可供使用-swift是其中之一,在Symfony之类的框架中被使用,因此应得到良好的支持。

As it seems that you are on windows the most easy way is to seman mail trough a smtp server. 好像您在Windows上一样,最简单的方法是通过smtp服务器发送邮件。 For that you can use the mail class from Pear -> http://pear.php.net/package/Mail 为此,您可以使用Pear中的邮件类-> http://pear.php.net/package/Mail

PHP needs a mail server to deliver messages. PHP需要一个邮件服务器来传递消息。 In your php.ini file you'll find this directive: 在您的php.ini文件中,您将找到以下指令:

[mail function]
; For Win32 only.
SMTP = smtp.example.com
smtp_port = 25

; For Win32 only.
sendmail_from = webmaster@example.com

Edit the file and fill the values with your e-mail provider information. 编辑文件,并用您的电子邮件提供商信息填充值。

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

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