<? class CMailFile { var $subject; var $addr_to; var $text_body; var $text_encoded; var $mime_headers; var $mime_boundary = "--==================_846811060==_"; var $smtp_headers; function CMailFile($subject,$to,$from,$msg,$filename,$downfilename,$mimetype = "application/octet-stream",$mime_filename = false) { $this->subject = $subject; $this->addr_to = $to; $this->smtp_headers = $this->write_smtpheaders($from); $this->text_body = $this->write_body($msg); $this->text_encoded = $this->attach_file($filename,$downfilename,$mimetype,$mime_filename); $this->mime_headers = $this->write_mimeheaders($filename, $mime_filename); } function attach_file($filename,$downfilename,$mimetype,$mime_filename) { $encoded = $this->encode_file($filename); if ($mime_filename) $filename = $mime_filename; $out = "--" . $this->mime_boundary . "\n"; $out = $out . "Content-type: " . $mimetype . "; name=\"$filename\";\n"; $out = $out . "Content-Transfer-Encoding: base64\n"; $out = $out . "Content-disposition: attachment; filename=
This is a php attachment email class, friends who need it can download and use
All resources on this site are contributed by netizens or reprinted by major download sites. Please check the integrity of the software yourself! All resources on this site are for learning reference only. Please do not use them for commercial purposes. Otherwise, you will be responsible for all consequences! If there is any infringement, please contact us to delete it. Contact information: admin@php.cn
Related Article

22 Jul 2025
TosendanemailwithanattachmentinPHPusingthemail()function,youmustmanuallyhandleMIMEencodingbybuildingamultipartmessage,encodingtheattachmentinbase64,andsettingthecorrectheaders.1.Ensureyourserverisconfiguredtosendemailsandtheattachmentfileisreadable.2

01 Aug 2025
To send emails with attachments, you need to use smtplib and email modules, 1. Configure sender, recipient, password and SMTP server; 2. Create a MIMEMultipart message and set the sender, recipient and subject; 3. Add the email text; 4. Use MIMEBase to read the file and encode it as base64, and add the attachment header; 5. Connect to smtp.gmail.com:587, enable TLS, log in and send the email, and finally close the connection. After the email is sent successfully, it will prompt "Emailsentsuccessfully!".

25 Nov 2024
PHP Libraries for Email Address ValidationValidating email addresses can be a challenging task, especially if you need to adhere to industry...

18 Nov 2024
PHP Email Address Validation Libraries UncoveredEmail address validation plays a crucial role in data validation, but creating a...

18 Jul 2025
Yes,youcansendanemailasanattachmentinGmailusingthreemethods.1.Ondesktop,opentheemail,clickthethreedots,select“Downloadmessage”tosaveitasa.emlfile,thenattachthatfiletoanewemail.2.IfusingOutlookconnectedtoyourGmailaccount,usethe“Forwardasattachment”opt

17 Mar 2025
The article explains how to use phpStudy for testing PHP email sending, detailing installation, configuration, and script examples. It discusses SMTP, Sendmail, and third-party libraries like PHPMailer.


Hot Tools

PHP library for dependency injection containers
PHP library for dependency injection containers

A collection of 50 excellent classic PHP algorithms
Classic PHP algorithm, learn excellent ideas and expand your thinking

Small PHP library for optimizing images
Small PHP library for optimizing images
