Before the expiration time, I plan to do something that sends the registration information to the user's mailbox after the user registration is complete,
Put it in the space I rented in mvbb. Of course, I plan to implement it in PHP. However, PHP only carries a mail ().
Send an email. However, the premise of using mail () is to have a mail system (such as Qmail ). But in my rent
Generally, space is impossible. Can I use the account I registered at www.126.com, and then use the 126
What about SMTP sending? Simply using mail () is definitely not acceptable, because mail () does not provide an interface for verification.
Well, what should I do next. (Give me a try.Source code!! >_< !!)
Yes, SourceCodeAs follows:
<? PHP
Require_once 'mail. php ';
$ Conf ['mail'] = array (
'Host' => 'smtp .126.com ', // SMTP server address
'Auth' => true, // true indicates that the SMTP server needs to be verified, and false does not.
'Username' => 'liangbowen ', // User Name
'Password' => '******' // Password
);
// Send an email
$ Headers ['from'] = 'liangbowen @ 126.com '; // mail address
$ Headers ['to'] = 'liangbowen @ hotmail.com '; // recipient address
$ Headers ['subobject'] = 'test Mail Send by PHP bowen.mvbb.com '; // mail title
$ Mail_object = & mail: Factory ('smtp ', $ conf ['mail']);
// Body of the email
$ Body = "this is an email sent to you. ";
$ Mail_res = $ mail_object-> send ($ headers ['to'], $ headers, $ body); // send
If (Pear: iserror ($ mail_res) {// check the error
Die ($ mail_res-> getmessage ());
}
Else {
Echo "Send successful! ";
}
?>
As you can see, to use the socket and SMTP class of pear, you can download it from pear. Of course, you can also write SMTP and socket classes by yourself.
Pay source code: http://www.liangbowen.com/downloads/mail.zip
Because it is for learning reference, it is just a very simple example, and the file is also a bit messy.