To make life difficult, the client I'm working on uses a really big, but old system that runs on PHP4.0 and they donβt want to add additional libraries.
I am trying to send email via PHP with an attachment and accompanying text / html content, but I cannot send them in a single email.
Sends an attachment:
$headers = "Content-Type: text/csv;\r\n name=\"result.csv\"\r\n Content-Transfer-Encoding: base64\r\n Content-Disposition: attachment\r\n boundary=\"PHP-mixed-".$random_hash."\""; $output = $attachment; mail($emailTo, $emailSubject, $output, $headers);
This sends the text / html:
$headers = "Content-Type: text/html; charset='iso-8859-1'\r\n"; $output = $emailBody;
This sends the attachment containing the text / html, along with the contents of the attachment:
$headers = "Content-Type: text/html; charset='iso-8859-1'\r\n".$emailBody."\r\n"; $headers = "Content-Type: text/csv;\r\n name=\"result.csv\"\r\n Content-Transfer-Encoding: base64\r\n Content-Disposition: attachment\r\n boundary=\"PHP-mixed-".$random_hash."\""; $output = $attachment;
I need to know how I can send an email with the text / html to the email body and also add an attachment to it. I am sure that I am missing something very simple here!
Thanks in advance.
James donnelly
source share