mail()
function. And here many beginner developers have a problem . The script, which works fine on the host server, gives errors on the local computer.
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 E:\www\simplemail\mailer.php on line ......
[mail function]
SMTP =
sendmail_from =
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t"
smtp_server=smtp.mail.ru
; SMTP server address
smtp_port=25
; SMTP server port
default_domain=mail.ru
; default domain
error_logfile=error.log
; error log file
debug_logfile=debug.log
; very useful option at the debugging stage. Logs all operations that sendmail performs.
auth_username=account_name@mail.ru
; your account name
auth_password=account_password
; your password
pop3_server=pop.mail.ru
pop3_username=account_name@mail.ru
pop3_password=account_password
force_sender=account_name@mail.ru
hostname=mail.ru
01 <html xmlns = "http://www.w3.org/1999/xhtml"> 02 <head> 03 <meta http-equiv = "Content-Type" content = "text / html; charset = utf-8" /> 04 <title> Simple Mail </ title> 05 </ head> 06 <body> 07 <? Php 08 $ addr = $ _POST ['addr']; 09 $ theme = $ _POST ['theme']; 10 $ text = $ _POST ['text']; 11 if (isset ($ addr) && isset ($ theme) && isset ($ text) 12 && $ addr! = "" && $ theme! = "" && $ text! = "") { 13 if (mail ($ addr, $ theme, $ text, "From: vova_33@mail.ru")) { 14 echo "<h3> Message sent </ h3>"; 15 } 16 else { 17 echo "<h3> An error occurred while sending the message </ h3>"; 18 } nineteen } 20?> 21 <form action = "mailer.php" method = "post"> 22 <p> 23 <label for = "addr"> eMail: </ label> 24 <input type = "text" name = "addr" id = "addr" size = "30" /> 25 </ p> 26 <p> 27 <label for = "theme"> Letter subject: </ label> 28 <input type = "text" name = "theme" id = "theme" size = "30" /> 29 </ p> 30 <p> 31 <label for = "text"> Letter text: </ label> 32 <textarea rows = "10" cols = "20" name = "text" id = "text"> </ textarea> 33 </ p> 34 <p> 35 <input type = "submit" value = "Send" /> 36 </ p> 37 </ form> 38 </ body> 39 </ html>
Source: https://habr.com/ru/post/26518/