您好,欢迎访问一九零五行业门户网

phpmailer发送gmail邮件的例子

本文介绍下,使用phpmailer发送gmail邮件的例子,有需要的朋友参考下吧。使用phpmailer类发送gmail邮件实例代码:
phpmailer-发送gmail邮件_bbs.it-home.orgissmtp(); // telling the class to use smtp$mail->host = mail.gmail.com; // smtp server$mail->smtpdebug = 2; // enables smtp debug information (for testing)// 1 = errors and messages// 2 = messages only$mail->smtpauth = true; // enable smtp authentication$mail->smtpsecure = ssl; // sets the prefix to the servier$mail->host = smtp.gmail.com; // sets gmail as the smtp server$mail->port = 465; // set the smtp port for the gmail server$mail->username = ***@gmail.com; // gmail username$mail->password = ***; // gmail password$mail->setfrom('****@gmail.com', 'first last');$mail->addreplyto(***@gmail.com,first last);$mail->subject = phpmailer test subject via smtp (gmail), basic;$mail->altbody = to view the message, please use an html compatible email viewer!; // optional, comment out and test$mail->msghtml($body);$address = ***@gmail.com;$mail->addaddress($address, john doe);$mail->addattachment(images/phpmailer.gif); // attachment$mail->addattachment(images/phpmailer_mini.gif); // attachmentif(!$mail->send()) { echo mailer error: . $mail->errorinfo;} else { echo message sent!;}?>
需要引入phpmailer类文件,下载地址:phpmailer邮件发送类v5.1下载地址。
其它类似信息

推荐信息