Using the Zend in the Zend Framework frame

Source: Internet
Author: User
Tags mail zend zend framework

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!




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.