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;
} |