As we all know, Zend Framework is a standard PHP5 Framework developed by zend. It includes almost all of the function modules we often use, such as feed, mail, cache, db, etc. Today we mainly introduce the Zend_Mail module to help us send application information to the Administrator and the customer in a timely manner.
The following is a code block I wrote. This code is used to send emails through SMTP. You need to provide the user name, password, and host address. This is also the usual email logon method.
Require_once Zend/Mail. php;
Require_once Zend/Mail/Transport/Smtp. php;
Class logMail {
Private static $ _ config = array (auth => login,
Username => XXXX@yuyu.com,
Password => XXXX );
Private static $ _ mail = null;
Private static $ _ transport = null;
Public function _ construct ($ title, $ body ){
Try {
$ Shijie = date (Y-m-d );
$ Transport = new Zend_Mail_Transport_Smtp (mail.yuyu.com, self: $ _ config );
$ Mail = new Zend_Mail ();
$ Mail-> setBodyText ($ body );
$ Mail-> setFrom (XXX@yuyu.com, XXX );
$ Mail-> addTo (XXX@163.com, XXX );
$ Mail-> setSubject ($ title. (. $ shijie .));
$ Mail-> send ($ transport );
Return true;
} Catch (Exception $ e ){
$ E-> getTrace ();
Return false;
}
Return false;
}
Public static function logMail ($ title, $ body ){
$ This->__ construct ($ title, $ body );
}
Public function _ destruct (){
}
}
New logMail (Test, Test );
Through the above Code, you only need to change the user name and password to your own, and then you can freely apply the user name and password in the application, more important applications may be log sending and Project sending!