As we all know, the Zend Framework is a standard PHP5 version of the framework developed by Zend, which includes nearly all of the functional modules we use, such as feed,mail,cache,db and so on, today we mainly introduce the Zend_mail module, To help us timely application of the information to the administrator to send to the customer.
Here is a block of code I wrote, the code is sent through SMTP to send mail, need to provide the user name, password and host address, which is often used by the mail login 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, we only need to change the username and password for their own, it can be used in the application of the random he came, more important application may be more log sent and the project sent!