Phpmailer is a packaged PHP mail sending class, support for sending HTML content of e-mail, and can add attachments to send, not like the php itself mail () function requires server environment support, you only need to set up the mail server with relevant information to achieve the mail delivery function.
First you need to download the Phpmailer class package: Click to download
The PHP code is implemented as follows:
<?phprequire (' class.phpmailer.php '); $mail = new Phpmailer (); Instantiation of $MAIL->ISSMTP (); Enable Smtp$mail->host = "smtp.163.com"; SMTP Server 163 Mailbox example//$mail->host = "smtp.126.com"; SMTP Server 126 Mailbox example//$mail->host = "smtp.qq.com"; SMTP server QQ Mailbox Example $mail->port = 25; Mail send Port $mail->smtpauth = true; Enable SMTP Authentication $mail->charset = "UTF-8"; Character Set $mail->encoding = "Base64"; Encoding mode $mail->username = "abc@163.com"; Your mailbox $mail->password = "XXX"; Your password $mail->subject = "xxx Hello"; Message title $mail->from = "Abc@163.com"; The sender's address (that is, your mailbox) $mail->fromname = "xxx"; Sender name $address = "xxx@qq.com";//Recipient email$mail->addaddress ($address 1, "xxx1"); Add recipient 1 (address, nickname) $mail->addaddress ($address 2, "xxx2"); Add recipient 2 (address, nickname) $mail->addattachment (' Xx.xls ', ' my attachments. xls '); Add the attachment and specify the name $mail->addattachment (' Xx1.xls ', ' My Attachment 1.xls '); Multiple attachments can be added $mail->addattachment (' Xx2.xls ', ' My Attachments 2.xls '); Multiple attachments can be added $mail->ishtml (true); Supports HTML-formatted content $mail->addembeddedimage ("logo.jpg", "my-aTtach "," logo.jpg "); Set a picture in a message $mail->body = ' Hello, <b> friend </b>! <br/> this is an email! '; Message body content//Send if (! $mail->send ()) {echo "Send failed:". $mail->errorinfo;} else {echo "Success";}? >
Attached: Common mailbox Server (SMTP, POP3) address, port
Sina.com:POP3 Server address: pop3.sina.com.cn (port: +) SMTP server address: smtp.sina.com.cn (port:) SINAVIP:POP3 Server: Pop3.vip.sina.com (port: +) SMTP server: smtp.vip.sina.com (port: sohu.com:POP3) server address: pop3.sohu.com (port: 110) SMTP Server address: smtp.sohu.com (port: 126) mailbox: POP3 server address: pop.126.com (port: +) SMTP server address: smtp.126.com (port: 139) e-mail: POP3 Server address: pop.139.com (port: +) SMTP server address: smtp.139.com (port: +) 163.COM:POP3 server address: pop.163.com (port: +) SMTP Server address: Smtp.163.com (port: +) QQ mailbox POP3 server address: pop.qq.com (port: +) SMTP server address: smtp.qq.com (port:) QQ Enterprise Mailbox POP3 Server address: pop.exmail.qq.com (SSL enabled port: 995) SMTP Server address: smtp.exmail.qq.com (SSL Enable port: 587/465) yahoo.com:POP3 server address: pop.mail.yahoo.com SMTP Server address: smtp.mail.yahoo.com yahoo.com.cn:POP3 server address: pop.mail.yahoo.com.cn (port: 995) SMTP Server address: smtp.mail.yahoo.com.cn (port: 587