Use LINUXSENDMAIL to send emails

Source: Internet
Author: User
Use LINUXSENDMAIL to send an email-Linux Enterprise Application-Linux server application information. The following is a detailed description. Today, I wrote an email sending program using sendmail installed in linux. The Code is as follows:

The parameters are Email address, Email title, and content! You must also define the MAIL_HOST and MAIL_SENDER constants.
CODE: define ('mail _ host', '192. 168.1.131 ');
Define ('mail _ sender', 'test @ test.com ');
Static function SendMail ($ email, $ title, $ content ){
Include_once (PATH_CLASS. '/phpmailer/class. phpmailer. php ');
$ Mail = new PHPMailer ();
$ Mail-> CharSet = "GBK ";
$ Mail-> IsSendmail ();
$ Mail-> Host = MAIL_HOST;
$ Mail-> SMTPAuth = true; // set it to the security authentication method.
$ Mail-> SetLanguage ('en', PATH_CLASS. '/phpmailer/language /');
$ Mail-> From = MAIL_SENDER;
$ Mail-> FromName = "service ";
$ Mail-> AddAddress ($ email, 'shellnet'); // recipient address
$ Mail-> WordWrap = 50; // set word wrap to 50 characters
$ Mail-> IsHTML (true); // you can specify the email format as HTML.
$ Mail-> Subject = iconv ("UTF-8", "gb2312", $ title );
$ Mail-> Body = iconv ("UTF-8", "gb2312", $ content );
$ Result = $ mail-> Send ();
$ Mail-> SmtpClose ();
Return $ result;
}

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.