Gcobani Posted March 10, 2023 Share Posted March 10, 2023 Hi Team I have tried to create send email using php mail function and attach one file, but the issue i am facing now pdf document is only shown on html content not displaying it as a pdf and need some around my logic below. <?php $filenameee = $_FILES['id']['name']; $message = "Name: ". $fname . $lname . "\r\n Email: " . $email . "\r\n Cell Number: " . $number . "\r\n Monthly Income: " . $income . "\r\n Loan Amount: " . $amount . "\r\n Town:" . $town . "\r\n id :.$filenameee."; $subject ="Application Form"; $fromname ="ACI FINANCE"; $fromemail = $email; //if u dont have an email create one on your cpanel $mailto = 'gcobani.mkontwana@agilelimitless.org.za'; //the email which u want to recv this email // Define the message body $body = '--'.$separator.$eol; $body .= 'Content-Type: text/plain; charset="iso-8859-1"'.$eol; $body .= 'Content-Transfer-Encoding: 8bit'.$eol.$eol; $body .= $message.$eol; // Define the first attachment $filenameee = 'public_html/PHPMailer/path/to/attachment1/id.pdf'; $file_size = filesize($filenameee); $file_name = basename($filenameee); $handle = @fopen($filenameee, 'rb'); $content = @fread($handle, $file_size); @fclose($handle); $attachment = chunk_split(base64_encode($content)); $body .= '--'.$separator.$eol; $body .= 'Content-Type: application/pdf; name="'.$file_name.'"'.$eol; $body .= 'Content-Transfer-Encoding: base64'.$eol; $body .= 'Content-Disposition: attachment; filename="'.$file_name.'"'.$eol.$eol; $body .= $attachment.$eol; $body .= '--'.$separator.'--'.$eol; ?> Quote Link to comment https://forums.phpfreaks.com/topic/315994-html-content-pdf-is-not-displaying-pdf-when-viewed-using-php-mail/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.