Jump to content

[SOLVED] send attachement with mail()


sheriff

Recommended Posts

Please help me in this:

 

How can i send the oferta.pdf as attachement ?

 

Thanks !

 

<?php

// Turn off all error reporting
error_reporting(1);

// Report all PHP errors (bitwise 63 may be used in PHP 3)
error_reporting(E_ALL);

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);

// The mailing system
$today = date('d-m-Y H:i');
$attachment = chunk_split(file_get_contents("oferta.pdf")); 
$random_hash = md5(date('r', time()));
$headers = "From: [email protected] \r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-type: application/pdf;\r\n";
$headers .= "$attachment\r\n";

$mail_sent = @mail($_POST['to'] . ", [email protected]", $_POST['subject'], $_POST['message'] . $attachement, $headers);

echo $mail_sent ? "<div style=\"margin-top: 10; margin-left: 300\" align=\"left\">Mail sent!<br>"." TO: $_POST[to]<br>" .
                                  "CC: [email protected]<br>" .
                                  "Message: $_POST[message]</div>": "<center>Mail failed</center>"; 
?>
<div align="center"><a href="index.php" style="text-decoration: none">Back</a></div>

Link to comment
https://forums.phpfreaks.com/topic/47215-solved-send-attachement-with-mail/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.