Phpmailer Mail Send ____php

Source: Internet
Author: User
Tags base64 echo message function prototype win32
This is the use of open source project Phpmailer to achieve mail, first download files, I download here is 5.1 version, and then put three class.***.php files to the project file, I first use is Gmail, but failed, the problem is authentication failed, and later used the QQ mailbox, sent successfully. Tags:Send mail code fragment (1) [Full screen view all code] 1. [Code][php] code
01 <?php
02 Require ("class.phpmailer.php"); The downloaded file must be placed in the same directory as the file
03 $mail = new Phpmailer (); Create a mail delivery class
04 $address = "youbinliu@126.com";
05 $mail->issmtp (); Send using SMTP method
06 $mail->host = "smtp.qq.com"; Your Business Post office domain name
07 $mail->smtpauth = true; To enable the SMTP authentication feature
08 $mail->username = "843831601@qq.com"; Post Office username (please fill in the full email address)
09 $mail->password = "***********"; Post Office password
10 $mail->port=25;
11 $mail->from = "843831601@qq.com"; Mail Sender email Address
12 $mail->fromname = "Liuyoubin";
13 $mail->addaddress ("$address", "a");//recipient address, can be replaced by any e-mail message that you want to receive mail, in the form of addaddress ("addressee Email", "Recipient Name")
14 $mail->addreplyto ("", "");
15
16 $mail->addattachment ("/var/tmp/file.tar.gz"); Add attachment
17 $mail->ishtml (TRUE); Set email format to HTML//whether to use HTML format
18
19 $mail->subject = "phpmailer test mail"; Message headers
20 $mail->body = "Hello, this is Test mail"; Message content
21st $mail->altbody = "This are the body in plain text for non-html mail clients"; Additional information that can be omitted
22
23 if (! $mail->send ())
24 {
25 Echo message failed to send. <p> ";
26 echo "Error Reason:". $mail->errorinfo;
27 Exit
28 }
29
30 echo "Mail sent successfully";
31
32
33 /*************************************************
34
35 Attachment:
36 Phpmailer Chinese usage instructions (simple version)
37 A begins:
38 $AltBody--Properties
39 Originated from: Phpmailer:: $AltBody
40 File: class.phpmailer.php
41 Description: This property is set to an alternate display that does not support HTML in the message body
42 addaddress--method
43 From: Phpmailer::addaddress (), File: class.phpmailer.php
44 Description: Increase the recipient. Parameter 1 is the recipient's mailbox, and Parameter 2 is the recipient's salutation. Example AddAddress ("eb163@eb163.com", "eb163"), but parameter 2 is optional, addaddress (eb163@eb163.com) is also possible.
45 Function prototype: Public function addaddress ($address, $name = ' ") {}
46 addattachment--method
47 Derived from: Phpmailer::addattachment ()
48 File: class.phpmailer.php.
49 Description: Add accessories.
50 Parameters: Path, name, encoding, type. Where the path is required, others are optional
51 Function Prototypes:
52 AddAttachment ($path, $name = ', $encoding = ' base64 ', $type = ' Application/octet-stream ') {}
53 addbcc--method
54 Derived from: PHPMAILER::ADDBCC ()
55 File: class.phpmailer.php
56 Description: Add a secret send. The difference between CC and BCC see [the difference between BCC and CC in SMTP senders].
57 Parameter 1 is the address, and parameter 2 is the name. Note This method only supports the use of SMTP under Win32, and does not support mail functions
58 Function prototype: Public function addbcc ($address, $name = ' ") {}
59 ADDCC--method
60 Derived from: PHPMAILER::ADDCC ()
61 File: class.phpmailer.php
62 Description: Add a CC. The difference between CC and BCC see [the difference between BCC and CC in SMTP senders].
63 Parameter 1 is the address, parameter 2 is the name note This method only supports the use of SMTP under Win32, and does not support mail functions
64 Function prototype: Public function ADDCC ($address, $name = ' ") {}
65 addcustomheader--method
66 Derived from: Phpmailer::addcustomheader ()
67 File: class.phpmailer.php
68 Description: Add a custom email head.
69 parameter is header information
70 Function prototype: Public function Addcustomheader ($custom _header) {}
71 Addembeddedimage--method
72 Derived from: Phpmailer::addembeddedimage ()
73 File: class.phpmailer.php
74 Description: Add an embedded picture
75 Parameters: path, return handle [, Name, encoding, type]
76 Function prototypes: Public function Addembeddedimage ($path, $cid, $name = ', $encoding = ' base64 ', $type = ' Application/octet-stream ') { }
77 Hint: Addembeddedimage (picture_path. "Index_01.jpg", "img_01", "index_01.jpg");
78 Referencing in HTML
79 addreplyto--method
80 Originated from: Phpmailer:: Addrepl
81 *************************************************/
82 ?>

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.