For questions about sending emails via php and mail (), I would like to ask if I am studying the basic syntax in w3school and see the case of sending emails.
$ To = "someone@example.com ";
$ Subject = "Test mail ";
$ Message = "Hello! This is a simple email message .";
$ From = "someonelse@example.com ";
$ Headers = "From: $ from ";
Mail ($ to, $ subject, $ message, $ headers );
Echo "Mail Sent .";
?>
Test failed to send email
I would like to ask if php mail can be implemented with just a few simple codes? Do you not need the sender's account password or other settings?
Reply to discussion (solution)
Use php mailer to mail please refer to video tutorial http://pan.baidu.com/s/1rIJeU or http://www.zixue.it/portal.php? Mod = list & catid = 11
The mail function can only send emails using a sender server that does not require user authentication.
If you use a sender server that does not require user authentication, you must configure it in php. ini to use the mail function.
Require_once ('email. class. php ');
//###################################### ####
$ Smtpserver = "smtp.163.com"; // SMTP server
$ Smtpserverport = 25; // SMTP server port
$ Smtpusermail = "your @ 163.com"; // SMTP server user email
$ Smtpemailto = $ email; // to whom the email is sent
$ Smtpuser = "name"; // User account of the SMTP server
$ Smtppass = "addfgtpd"; // user password of the SMTP server
$ Mailsubject = "subject"; // subject
$ Mailbody = "Mail content" // mail content
$ Mailtype = "HTML"; // The email format (HTML/TXT). TXT is a text email.
$ Smtp = new smtp ($ smtpserver, $ smtpserverport, true, $ smtpuser, $ smtppass); // Here, true indicates that authentication is used; otherwise, authentication is not used.
$ Smtp-> debug = FALSE; // whether to display the sent debugging information
$ Smtp-> sendmail ($ smtpemailto, $ smtpusermail, $ mailsubject, $ mailbody, $ mailtype );
?>
If you need to authenticate, use phpmailer. you can simply configure it a few times.