简体   繁体   中英

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\\

please sugest me that what i have to do for send data to a mail id properly

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 .

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, ...)


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.

As it seems that you are on windows the most easy way is to seman mail trough a smtp server. For that you can use the mail class from Pear -> http://pear.php.net/package/Mail

PHP needs a mail server to deliver messages. In your php.ini file you'll find this directive:

[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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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