File manager - Edit - /home/custbahd/public_html/email/sendmail/sendmail-with-attachment.php
Back
<?php $file = "example.txt"; $to = 'iann@customassistinc.com'; $subject = 'Mail With File'; $content = file_get_contents($file); $encodedContent = chunk_split(base64_encode($content)); $divider = md5(time()); $headers = "From: Custom Assist Inc. <info@customassistinc.com>\r\n"; $headers .= "Content-Type: multipart/mixed; boundary=\"" . $divider . "\"\r\n"; $headers .= "Content-Transfer-Encoding: 7bit\r\n"; // prepare mail body with attachment $message = "--" . $divider. "\r\n"; $message .= "Content-Type: application/octet-stream; name=\"" . $file . "\"\r\n"; $message .= "Content-Transfer-Encoding: base64\r\n"; $message .= "Content-Disposition: attachment\r\n"; $message .= $encodedContent. "\r\n"; $message .= "--" . $divider . "--"; //sendmail with attachment if (mail($to, $subject, $message, $headers)) { echo 'Mail sent successfully.'; } else { echo 'Unable to send mail. Please try again.'; } ?>
| ver. 1.4 |
Github
|
.
| PHP 8.1.33 | Generation time: 1 |
proxy
|
phpinfo
|
Settings