Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 12th, 2005, 09:57 PM
Authorized User
 
Join Date: May 2004
Posts: 15
Thanks: 0
Thanked 0 Times in 0 Posts
Default Sending multipart/alternative emails with attachme

 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:

PHP Code:
#---------- #2 ----------------------------------
$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>"
;

$headers "From:"$_POST['from'] . "\n";
$headers .= "Bcc:" $bcc "\n";
$headers .= "CC: [email][email protected][/email]";

$semi_rand md5(time());
$mime_boundary "==Multipart_Boundary_x{$semi_rand}x";

$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed; type=multipart/alternative; \n" .
" boundary=\"{$mime_boundary}\"";

//---- send plain text -------
$headers .= "Content-type: text/plain; charset=iso-8859-1\r\n";
$headers .= "This is the plain version";
//----------------------------

//---- start message ---------
$message .= "This is a multi-part message in MIME format.\n\n" .
"--{$mime_boundary}\n" .
"Content-Type: text/html; charset=\"iso-8859-1\"\n" .
"Content-Transfer-Encoding: 7bit\n\n" .
$message "\n\n";


if(
is_uploaded_file$file_attachment ) )
{
$file fopen($file_attachment,'rb');
$data fread($file,filesize($file_attachment));
fclose($file);
$data chunk_split(base64_encode($data));

$message .= "--{$mime_boundary}\n" ;
$message .= "Content-Type: {$file_attachment_type};\n";
$message .= " name=\"{$file_attachment_name}\"\n";
$message .= "Content-Disposition: attachment;\n";
$message .= " filename=\"{$file_attachment_name}\"\n";
$message .= "Content-Transfer-Encoding: base64\n\n";
$message .= $data "\n\n";
$message .= "--{$mime_boundary}--\n";

echo 
"<br>duh";
}

#----------------------------------------------------


#########################################
if( $_REQUEST['action_mail'] )
{
if (
mail($to$subject$message$headers) )
{
$confirm "Message Sent!";
}
else{ 
$confirm "Failed to send message."; }
}
######################################### 
This seems to work but when I view it in Eudora, it shows the html code litterally.

Any ideas?

Clem C

 
Old April 26th, 2005, 07:43 PM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Use http://phpmailer.sourceforge.net/ , it'll do it all for you.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending Html Emails through DTS cvnitkumar SQL Server DTS 1 January 9th, 2007 01:00 PM
Sending automatic emails maitias C# 2005 3 March 3rd, 2006 09:51 PM
Sending emails from smartphone application. unprsandeep C# 0 March 24th, 2005 02:01 PM
Sending automatic emails in Access marcin2k Access VBA 10 March 6th, 2005 03:48 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.