Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn how to use the email sending system found by tp. It will not succeed after trial on this server, specially changed to this type of email sending
In config. php, Please modify the account password and smtp as needed
'Think _ EMAIL '=> array (
'Smtp _ host' => 'smtp .qq.com ', // SMTP Server
'Smtp _ port' => '25', // SMTP server PORT
'Smtp _ user' => '6 @ qq.com ', // SMTP Server Username
'Smtp _ pass' => '123', // SMTP server password
'From _ EMAIL '=> '6 @ qq.com', // sender EMAIL
'From _ name' => 'cc', // sender NAME
'Reply _ EMAIL '=> '', // REPLY to the EMAIL (if left blank, It is the sender EMAIL)
'Reply _ name' => '', // reply name (if left blank, It is the sender NAME)
),Add a method to index or other controllers and copy the following code.
Import ("@. LibHM. Smtp"); // mail sending class
$ Config_mail = C ('Think _ EMAIL ');
$ Smtpserver = $ config_mail ['smtp _ host']; // SMTP Server
$ Smtpserverport = $ config_mail ['smtp _ port']; // SMTP server PORT
$ Smtpusermail = $ config_mail ['from _ EMAIL ']; // user EMAIL address of the SMTP server
$ Smtpuser = $ config_mail ['smtp _ user']; // USER Account of the SMTP server
$ Smtppass = $ config_mail ['smtp _ pass']; // user password of the SMTP server
$ Smtpemailto = $ uemail; // who to send
$ Mailsubject = $ subject; // Email subject
$ Mailtime = date ("Y-m-d H: I: s ");
$ Mailbody = $ body; // email content
$ Utfmailbody = iconv ("UTF-8", "GB2312", $ mailbody); // convert the email code
$ 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 FALSE or TRUE
$ Ret = $ smtp-> sendmail ($ smtpemailto, $ smtpusermail, $ mailsubject, $ utfmailbody, $ mailtype );Returns true if the email is successfully sent.
Smtp.class.rar (2.18 KB download: 373 times)
AD: truly free, domain name + VM + enterprise mailbox = 0 RMB