This article mainly introduces php's use of the smtp class to easily send emails. The smtp method is actually very simple. For more information, see
This article mainly introduces php's use of the smtp class to easily send emails. The smtp method is actually very simple. For more information, see
The smtp mail method is simple and stable. You can send emails with a few simple configurations. Are you looking forward to a try!
The following is the core code:
<? Php require_once "email. class. php "; // ********************* configuration information **************** * *************** $ smtpserver = "smtp.126.com "; // SMTP server $ smtpserverport = 25; // SMTP server port $ smtpusermail = "new2008oh@126.com"; // SMTP server's user email $ smtpemailto = $ _ POST ['topin']; // send to $ smtpuser = "new2008oh"; // SMTP server user account $ smtppass = "your email password "; // SMTP server user password $ mailtitle =$ _ POST ['title']; // Email Subject $ mailcontent = "". $ _ POST ['content']. ""; // mail content $ mailtype = "HTML"; // mail 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 $ state = $ smtp-> sendmail ($ smtpemailto, $ smtpusermail, $ mailtitle, $ mailcontent, $ mailtype); echo"
"; If ($ state =" ") {echo" sorry, email sending failed! Check whether the email address is entered incorrectly. "; Echo" Click here to return "; exit ();} echo" Congratulations! Email sent !! "; Echo" Click here to return "; echo"
";?>
Effect appreciation:
The method shared in this article is simple and easy to understand.
The following is the source code provided for you: php uses the smtp class to send emails.