Phpmailer sends mail instance program

Source: Internet
Author: User
Tags base64 function prototype php file reset valid win32 word wrap port number
The code is as follows: Copy code

Require ("class. phpmailer. php ");
$ Mail = new phpmailer ();
$ Mail-> charset = 'utf-8 ';
$ Address = $ _ post ['address'];
$ Mail-> issmtp (); // set mailer to use smtp
$ Mail-> host = "mail.xxx.com"; // specify main and backup server
$ Mail-> smtpauth = true; // turn on smtp authentication
$ Mail-> username = "phpmailer@xxx.com"; // smtp username
$ Mail-> password = "******"; // smtp password

$ Mail-> from = "Enter the email you want to fill in here ";
$ Mail-> fromname = "the name to be displayed ";
$ Mail-> addaddress ("$ address ","");
// $ Mail-> addaddress (""); // name is optional
// $ Mail-> addreplyto ("","");

// $ Mail-> wordwrap = 50; // set word wrap to 50 characters
// $ Mail-> addattachment ("/var/tmp/file.tar.gz"); // add p_w_uploads
// $ Mail-> addattachment ("/tmp/image.jpg", "new.jpg"); // optional name
// $ Mail-> ishtml (true); // set email format to html

$ Mail-> subject = "phpmailer test email ";
$ Mail-> body = "hello, this is the test email of pine nuts ";
$ Mail-> altbody = "this is the body in plain text for non-html mail clients ";

If (! $ Mail-> send ())
{
Echo "message cocould not be sent. <p> ";
Echo "mailer error:". $ mail-> errorinfo;
Exit;
}

Echo "message has been sent ";

/*
$ Altbody -- attribute
From: phpmailer ::$ altbody
File: class. phpmailer. php
Note: the setting of this attribute is that html standby display is not supported in the mail body.

Addaddress -- method
From: phpmailer: addaddress (), File: class. phpmailer. php
Note: Add recipients. Parameter 1 is the recipient's mailbox, and parameter 2 is the recipient's name. Example addaddress ("to@163.com", "to name"), but parameter 2 is optional, addaddress (to@163.com) is also possible.
Function prototype: public function addaddress ($ address, $ name = ''){}

Addattachment -- method
From: phpmailer: addattachment ()
File: class. phpmailer. php.
Note: add attachments.
Parameter: Path, name, encoding, type. The path is required, and the others are optional.
Function prototype:
Addattachment ($ path, $ name = '', $ encoding = 'base64', $ type = 'application/octet-stream '){}

Addbcc -- method
From: phpmailer: addbcc ()
File: class. phpmailer. php
Note: add a BCC. For the differences between CC and BCC, see [differences between BCC and CC in smtp sending].
Parameter 1 is the address and parameter 2 is the name. Note that this method only supports smtp in win32 and does not support the mail function.
Function prototype: public function addbcc ($ address, $ name = ''){}

Addcc -- method
From: phpmailer: addcc ()
File: class. phpmailer. php
Note: add a CC. For the differences between CC and BCC, see [differences between BCC and CC in smtp sending].
Parameter 1 is the address and parameter 2 is the name. Note that this method only supports smtp in win32 and does not support the mail function.
Function prototype: public function addcc ($ address, $ name = ''){}

Addcustomheader -- method
From: phpmailer: addcustomheader ()
File: class. phpmailer. php
Note: add a custom email header.
The parameter is the header information.
Function prototype: public function addcustomheader ($ custom_header ){}

Addembeddedimage -- method
From: phpmailer: addembeddedimage ()
File: class. phpmailer. php
Add an embedded image.
Parameter: Path, return handle [, name, encoding, type]
Function prototype: public function addembeddedimage ($ path, $ cid, $ name = '', $ encoding = 'base64', $ type = 'application/octet-stream '){}
Tip: addembeddedimage (picture_path. "index_01.jpg", "img_01", "index_01.jpg ");
Reference

Addreplyto -- method
From: phpmailer: addreplyto ()
File: class. phpmailer. php
Note: add a reply tag, such as "reply-"
Parameter 1 address, parameter 2 name
Function prototype: public function addreplyto ($ address, $ name = ''){}

Addstringattachment-method
From: phpmailer: addstringattachment ()
File: class. phpmailer. php
Note: add a string or binary attachment (adds a string or binary attachment (non-filesystem) to the list .?)
Parameter: string, file name [, encoding, type]
Function prototype: public function addstringattachment ($ string, $ filename, $ encoding = 'base64', $ type = 'application/octet-stream '){}

Authenticate -- method
From: smtp: authenticate ()
File: class. smtp. php
Note: To start smtp authentication, it must be called after hello (). If the authentication succeeds, true is returned,
Parameter 1 user name, parameter 2 password
Function prototype: public function authenticate ($ username, $ password ){}

Start with B

$ Body -- attribute
From: phpmailer ::$ body
File: class. phpmailer. php
Description: email content, in html or text format

C

$ Charset -- attribute
From: phpmailer ::$ charset
File: class. phpmailer. php
English version (mail encoding, the default is ISO-8859-1)

$ Confirmreadingto -- attribute
From: phpmailer ::$ confirmreadingto File class. phpmailer. php
Note: receipt?

$ Contenttype -- attribute
From: phpmailer ::$ contenttype
File: class. phpmailer. php
Description: Document Type. The default value is "text/plain"

$ Crlf -- attribute
From: phpmailer ::$ contenttype
File: class. phpmailer. php
Note: smtp reply line ending ?)

Class. phpmailer. php -- object
From: class. phpmailer. php
File: class. phpmailer. php
Description: phpmailer object

Class. smtp. php -- object
From: class. smtp. php file: class. smtp. php
Description: smtp objects

Clearaddresses -- method
From: phpmailer: clearaddresses ()
File: class. phpmailer. php
Note: Clear the recipient to prepare for the next sending. The return type is void.

Clearallrecipients -- method
From: phpmailer: clearallrecipients ()
File: class. phpmailer. php
Note: clear all recipients, including cc (cc) and bcc (bcc)

Clearattachments -- method
From: phpmailer: clearattachments ()
File: class. phpmailer. php
Note: clear attachments

Clearbccs -- method
From: phpmailer: clearbccs () file class. phpmailer. php
Note: clear bcc)

Clearcustomheaders -- method
From: phpmailer: clearcustomheaders ()
File: class. phpmailer. php
Note: clear custom headers

Clearreplytos -- method
From: phpmailer: clearreplytos ()
File: class. phpmailer. php
Note: Clear the respondent

Close -- method
From: smtp: close ()
File: class. smtp. php
Disables an smtp connection.

Connect -- method
From: smtp: connect ()
File: class. smtp. php
Note: Create an smtpconnection mailer.html

$ Contenttype -- attribute
From: phpmailer ::$ contenttype
File: class. phpmailer. php
Description: Document Type. The default value is "text/plain"

Starting with d
$ Do_debug -- attribute
From: smtp: $ do_debug
File: class. smtp. php
Note: smtp debugging output

Data-method
From: smtp: data ()
File: class. smtp. php
Description: Sends a data command and message to the server (sendsthemsg_datatotheserver)

Start with e

$ Encoding -- attribute
From: phpmailer ::$ encoding
File: class. phpmailer. php
Description: sets the email encoding method. Optional values: "8bit", "7bit", "binary", "base64", and "quoted-printable ".

$ Errorinfo -- attribute
From: phpmailer ::$ errorinfo
File: class. phpmailer. php
Returns the last error message in smtp.


Expand -- method
From: smtp: expand ()
File: class. smtp. php
Note: all users in the email list are returned. If the call succeeds, an array is returned. Otherwise, false is returned .)

F:

$ From -- attribute
From: phpmailer ::$ from File class. phpmailer. php
Description: sender's email address.
$ Fromname -- attribute
From: phpmailer ::$ fromname
File: class. phpmailer. php
Description: sender's name.

H:

$ Helo -- attributes
From: phpmailer ::$ helo
File: class. phpmailer. php
Note: smtphelo is set. The default value is $ hostname (setsthesmtpheloofthemessage (defaultis $ hostname ).)

$ Host -- attribute
From: phpmailer ::$ host
File: class. phpmailer. php
Note: Set the smtp server in the format of host name [port number]. For example, smtp1.example.com: 25 and smtp2.example.com are both valid.

$ Hostname -- attribute
From: phpmailer ::$ hostname
File: class. phpmailer. php
Note: the hostname in message-id and andreceivedheaders is set and used by $ helo at the same time. If it is null, the default value is server_name or 'localhost. localdomain"

Hello -- method
From: smtp: hello ()
File: class. smtp. php
Note: The helo command is sent to the smtp server.

Help -- method
From: smtp: help ()
File: class. smtp. php
Note: If keyword exists, obtain help information for the keyword.

Start with I:

Iserror -- method
From: phpmailer: iserror ()
File: class. phpmailer. php
Indicates whether an error is returned.

Ishtml -- method
From: phpmailer: ishtml ()
File: class. phpmailer. php
Sets whether a letter is in html format.

Ismail -- method
From: phpmailer: ismail ()
File: class. phpmailer. php
Note: set whether to use the mail function of php for sending.

Isqmail -- method
From: phpmailer: isqmail ()
File: class. phpmailer. php
Description: Sets whether to use qmailmta for sending.

Issendmail -- method
From: phpmailer: issendmail ()
File: class. phpmailer. php
Indicates whether to use the $ sendmail program to send mails.

Issmtp -- method
From: phpmailer: issmtp ()
File: class. phpmailer. php
Indicates whether to use smtp for sending.

Start with m:

$ Mailer -- attributes
From: phpmailer ::$ mailer
File: class. phpmailer. php
Description: One of the sending methods ("mail", "sendmail", or "smtp").

Mail -- method
From: smtp: mail ()
File: class. smtp. php
Note: If an email address in $ from is processed, true or false is returned. If it is true, start sending

Starting with n:

Noop -- method
From: smtp: noop ()
File: class. smtp. php
Sends a noop command to the smtp server.

Start with p:
$ Password -- attribute
From: phpmailer ::$ password
File: class. phpmailer. php
Note: Set the smtp password.

$ Plugindir -- attribute
From: phpmailer ::$ plugindir
File: class. phpmailer. php
Description: sets the phpmailer plug-in directory, which is only valid when smtpclass is not in the phpmailer directory.

$ Port -- attribute
From: phpmailer: $ port
File: class. phpmailer. php
Description: sets the smtp port number.

$ Priority -- attribute
From: phpmailer ::$ priority
File: class. phpmailer. php
Note: mail delivery priority is set. 1 = urgent, 3 = normal, 5 = not urgent

Phpmailer -- object
From: phpmailer
File: class. phpmailer. php
Php: phpmailer-phpemailtransportclass

Start with q

Quit -- method
From: smtp: quit ()
File: class. smtp. php
Note: Send the quit command to the server. If no error occurs. Disable sock, otherwise $ close_on_error is true.

R

Recipient -- method
From: smtp: recipient ()
File: class. smtp. php
Note: Use to send the rcpt command to smtp. The parameter is $.

Reset -- method
From: smtp: reset ()
File: class. smtp. php
Note: The rset command is sent to cancel transmission during processing. True is returned if the call succeeds. Otherwise, false is returned.

Starting with s:

$ Sender -- attribute
From: phpmailer ::$ sender
File: class. phpmailer. php
Note: setsthesenderemail (return-path) ofthemessage. ifnotempty, willbesentvia-ftosendmailoras 'mailfrom' insmtpmode.

$ Sendmail -- attributes
From: phpmailer ::$ sendmail
File: class. phpmailer. php
Description: sets the Directory of the sender program.

$ Smtpauth -- attribute
From: phpmailer ::$ smtpauth
File: class. phpmailer. php
Description: Sets whether smtp authentication is required. The username and password variables are used.

$ Smtpdebug -- attributes
From: phpmailer ::$ smtpdebug
File: class. phpmailer. php
Note: set whether to debug the smtp output?

$ Smtpkeepalive -- attribute
From: phpmailer ::$ smtpkeepalive
File: class. phpmailer. php
Note: Do not close the connection after each sending. If the value is true, smtpclose () must be used to close the connection.

$ Smtp_port -- attribute
From: smtp: $ smtp_port
File: class. smtp. php
Note: Set the smtp Port

$ Subject -- attribute
From: phpmailer ::$ subject
File: class. phpmailer. php
Note: Set the subject of a letter.

Send -- method
From: smtp: send ()
File: class. smtp. php
Note: An email is transmitted from the specified email address.

Send -- method
From: phpmailer: send ()
File: class. phpmailer. php
Note: create an email and develop a sender program. If the sending fails, false is returned. Use errorinfo to view the error message.

Sendandmail -- method
From: smtp: sendandmail ()
File: class. smtp. php
Note: An email is transmitted from the specified email address.

Sendormail -- method
From: smtp: sendormail ()
File: class. smtp. php
Note: An email is transmitted from the specified email address.

Setlanguage -- method
From: phpmailer: setlanguage ()
File: class. phpmailer. php
Description: sets the language type of the phpmailer error message. If the language file cannot be loaded, false is returned. The default value is english.

Smtp -- method
From: smtp ()
File: class. smtp. php
Initialize an object so that the data is in a known state.

Smtp -- object
From: smtp
File: class. smtp. php
Description: smtp object

Smtpclose -- method
From: phpmailer: smtpclose ()
File: class. phpmailer. php
Note: If an active smtp exists, disable it.

Starting with t

$ Timeout -- attribute
From: phpmailer ::$ timeout
File: class. phpmailer. php
Note: Set the smtp server timeout (unit: seconds ). Note: In win32, this attribute is invalid.

Turn -- method
From: smtp: turn ()
File: class. smtp. php
Note: This is an optional smtp parameter. Currently phpmailer does not support this parameter and may be supported in the future.

U

$ Username -- attribute
From: phpmailer ::$ username
File: class. phpmailer. php
Sets the smtp user name.

V

$ Version -- attribute
From: phpmailer ::$ version
File: class. phpmailer. php
Returns the phpmailer version.

Verify -- method
From: smtp: verify ()
File: class. smtp. php
Note: Check whether the user name has been verified through the server

Start with w:

$ Wordwrap -- attribute
From: phpmailer ::$ wordwrap
File: class. phpmailer. php
Description: sets the maximum number of characters in each line. The line breaks automatically when the number is exceeded.

*/
?>

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.