-
- /**
- * PHPMailer email sending
- * Edit bbs.it-home.org
- */
- require_once('include/PHPMailer/class.phpmailer.php'); //Import PHPMAILER class
- $mail = new PHPMailer(); // Create an instance
- $mail -> CharSet='utf-8'; //Set the character set
- $mail -> SetLanguage('ch','include/PHPMailer/language/'); //Set the language type and language The directory where the file is located
- $mail -> IsSMTP(); //Use SMTP to send
- $mail -> SMTPAuth = true; //Set whether the server requires SMTP authentication
- $mail -> Host = SMTP_SERVER; // SMTP host address
- $mail -> Port = SMTP_SERVER_PORT; //SMTP host port
- $mail -> From = SMTP_USER_MAIL; //Sender's EMAIL address
- $mail -> FromName = 'jasonxu'; //Send The sender’s username in the SMTP host
- $mail -> Username = SMTP_USER_NAME; //The sender’s name
- $mail -> Password = SMTP_USER_PASS; //The sender’s password in the SMTP host
- $mail -> Subject = 'Test email title'; //Email subject
- $mail -> AltBody = 'text/html'; //Set the backup display when the email body does not support HTML
- $mail -> Body = 'Test the content of the email'; //The email content is made
- $mail -> IsHTML(true); //Is it an HTML email
- $mail -> AddAddress('chinajason2008#gmail.com','jasonxu' ); //The address and name of the recipient
- $mail -> AddReplyTo('chinajason2008#gmail.com','jasonxu'); //The address and name of the recipient when replying
- $mail -> ; AddAttachment('include/id.csv','att.csv'); //The path and name of the attachment
- if(!$mail -> Send()) //Send an email
- var_dump($mail -> ; ErrorInfo); //View the error message sent
- ?>
Copy code
Note: When phpmailer adds an attachment, the suffix of the attachment must be written in the name of the attachment. If not, the suffix of the attachment must be written. , the default attachment suffix will be .txt.
For example $mail -> AddAttachment('include/id.csv','att');//The path and name of the attachment
If you add an attachment and send it as above, the final attachment you receive may be att.txt.
AddAttachment can set the attachment encoding method and attachment type. For example, the above attachment addition can also be set to
$mail -> AddAttachment('include/id.csv','att.csv',"binary","text/comma-separated-values");//The path and name of the attachment,
There are several encoding methods for attachments: 8bit, base64, binary, and quoted-printable encoding are supported
The MIME Type accepted by CSV
· application/octet-stream
· text/comma-separated-values (recommended)
· text/csv
Therefore, the attachment type of the csv format file can be any of the above three types. 1 2 Next Page Last Page
|