Hello,
Is is possible to send a multipart/alternative html mail w/ attachments at the same time?
Here's some of the headings I have used w/ attacments:
$border_random = md5(time());
$mail_boundary = "x{$border_random}x";
$headers = "From: $from \r\n" ;
$headers .= "To: {$from}\r\n";
$headers .= "Reply-to: {$from}\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; \r\n";
$headers .= " boundary=\"".$mime_boundary."\"";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit \r\n";
$message .= "\r\n";
$message .= "<h1>$_REQUEST[form_message]</h1> \r\n";
$message .= "--".$mime_boundary."\r\n";
if(is_uploaded_file( $file_attachment ) )
{
$fp = fopen($file_attachment,"rb");
$file_data = fread($fp,$file_attachment_size);
fclose($fp);
$file = base64_encode($file_data);
$file = chunk_split($file);
$message .= "Content-Type: application/octet-stream;\r\n";
$message .= "Content-type: {$file_attachment_type}; name=\"$file_attachment_name\"\r\n";
$message .= "Content-Transfer-Encoding:base64 \r\n";
$message .= "Content-Disposition: attachment; filename=\"$file_attachment_name\"\r\n";
$message .= $file."\r\n";
}
$message .= "--{$mail_boundary}--\r\n";
This has worked great except for the fact that it doesn't seem to send images properly.
The next one sends a multipart/alternative email successfully:
$mime_boundary = "==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: $from\r\n" ;
$headers .= "Cc: $bcc \r\n";
$headers .= "Bcc: $bcc \r\n";
$headers .= "MIME-Version: 1.0\r\n" ;
$headers .= "Content-Type:multipart/alternative;\n";
$headers .= " boundary=\"{$mime_boundary}\"\r\n";
$message = "This is a multi-part message in MIME format.\n\n";
$message .= "--{$mime_boundary}\n" ;
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n" ;
$message .= "Content-Transfer-Encoding: 7bit\n\n" ;
$message .= "HTML E-mail\n\nThis is the text portion of an HTML e-mail\n" ;
$message .= "--{$mime_boundary}\n" .
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n" ;
$message .= "Content-Transfer-Encoding: 7bit\n\n" ;
$message .= "<html><body bgcolor=red>
<table width=200 bgcolor=red>
<tr><td>This is the <b>HTML portion</b> of the mixed message.</td></tr>
</table></body></html>";
Is there a successfull way to blend the functionality of both?
Is is possible to send a multipart/alternative html mail w/ attachments at the same time?
Here's some of the headings I have used w/ attacments:
$border_random = md5(time());
$mail_boundary = "x{$border_random}x";
$headers = "From: $from \r\n" ;
$headers .= "To: {$from}\r\n";
$headers .= "Reply-to: {$from}\r\n";
$headers .= "MIME-Version: 1.0\r\n";
$headers .= "Content-Type: multipart/mixed; \r\n";
$headers .= " boundary=\"".$mime_boundary."\"";
$message .= "This is a multi-part message in MIME format.\r\n";
$message .= "\r\n";
$message .= "--".$mime_boundary."\r\n";
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\r\n";
$message .= "Content-Transfer-Encoding: 7bit \r\n";
$message .= "\r\n";
$message .= "<h1>$_REQUEST[form_message]</h1> \r\n";
$message .= "--".$mime_boundary."\r\n";
if(is_uploaded_file( $file_attachment ) )
{
$fp = fopen($file_attachment,"rb");
$file_data = fread($fp,$file_attachment_size);
fclose($fp);
$file = base64_encode($file_data);
$file = chunk_split($file);
$message .= "Content-Type: application/octet-stream;\r\n";
$message .= "Content-type: {$file_attachment_type}; name=\"$file_attachment_name\"\r\n";
$message .= "Content-Transfer-Encoding:base64 \r\n";
$message .= "Content-Disposition: attachment; filename=\"$file_attachment_name\"\r\n";
$message .= $file."\r\n";
}
$message .= "--{$mail_boundary}--\r\n";
This has worked great except for the fact that it doesn't seem to send images properly.
The next one sends a multipart/alternative email successfully:
$mime_boundary = "==Multipart_Boundary_x".md5(mt_rand())."x";
$headers = "From: $from\r\n" ;
$headers .= "Cc: $bcc \r\n";
$headers .= "Bcc: $bcc \r\n";
$headers .= "MIME-Version: 1.0\r\n" ;
$headers .= "Content-Type:multipart/alternative;\n";
$headers .= " boundary=\"{$mime_boundary}\"\r\n";
$message = "This is a multi-part message in MIME format.\n\n";
$message .= "--{$mime_boundary}\n" ;
$message .= "Content-Type: text/plain; charset=\"iso-8859-1\"\n" ;
$message .= "Content-Transfer-Encoding: 7bit\n\n" ;
$message .= "HTML E-mail\n\nThis is the text portion of an HTML e-mail\n" ;
$message .= "--{$mime_boundary}\n" .
$message .= "Content-Type: text/html; charset=\"iso-8859-1\"\n" ;
$message .= "Content-Transfer-Encoding: 7bit\n\n" ;
$message .= "<html><body bgcolor=red>
<table width=200 bgcolor=red>
<tr><td>This is the <b>HTML portion</b> of the mixed message.</td></tr>
</table></body></html>";
Is there a successfull way to blend the functionality of both?