Jump to content

header multipart problem


darkfreaks

Recommended Posts

is there anyway to get this code working in MS outlook without switching to a more advanced mailer class???

 

 

just using the php mail function.as said before  it works in every other mailer but ocassionally it will download as zero bytes or give an error that the file is empty. from what i have been told by some trying to use it.

 

 

 

<?php
if (isset($_POST['submit'])){
$name="walpole-group.co.uk";

$to = "----"; 

$from = "----";

/* subject */
$subject = "Walpole Group Male Application Form";

foreach($_POST as $key => $val){
    	$_POST[$key] = trim($val);
}


$comDisplay12 =(isset($_POST['radio1']) && $_POST['radio1']=="Yes" ? " Yes " : " - ");

$comDisplay13 =(isset($_POST['radio2']) && $_POST['radio2']=="Yes" ? " Yes " : " - ");

$comDisplay14 =(isset($_POST['radio3']) && $_POST['radio3']=="Yes" ? " Yes " : " - ");

$comDisplay16 =(isset($_POST['piercings']) && $_POST['piercings']=="Yes" ? " Yes " : " - ");

$comDisplay17 =(isset($_POST['tattoos']) && !empty($_POST['tattoos']) ? $_POST['tattoos'] : " - ");	

$comDisplay18 =(isset($_POST['checkbox']) && !empty($_POST['checkbox']) ? $_POST['checkbox'] : " - "); 

$comDisplay19 =(isset($_POST['checkbox2']) && !empty($_POST['checkbox2']) ? $_POST['checkbox2'] : " - ");

$comDisplay20 =(isset($_POST['checkbox3']) && !empty($_POST['checkbox3']) ? $_POST['checkbox3'] : " - ");

$comDisplay21 =(isset($_POST['checkbox4']) && !empty($_POST['checkbox4']) ? $_POST['checkbox4'] : " - ");

$comDisplay21a =(isset($_POST['checkbox5']) && !empty($_POST['checkbox5']) ? $_POST['checkbox5'] : " - ");

$comDisplay22 =(isset($_POST['checkbox6']) && !empty($_POST['checkbox6']) ? $_POST['checkbox6'] : " - ");

$comDisplay23 =(isset($_POST['checkbox7']) && !empty($_POST['checkbox7']) ? $_POST['checkbox7'] : " - ");

	// if not empty file upload field
        if(!empty($_FILES['file_upload']['name'])) {
               
            $file_name = "{$_FILES['file_upload']['name']}";
            $tmp_name = "{$_FILES['file_upload']['tmp_name']}";
            $file_type = "{$_FILES['file_upload']['type']}";
		//echo "Error code is: {$_FILES['file_upload']['error']}";

		// get extension of file 
		$base = basename($file_name);
		//$ext = substr($base,strlen($base)-4, strlen($base));
		$ext = strtolower(pathinfo($base, PATHINFO_EXTENSION));
		//allowed extensions
		$allowed_ext= array('jpeg','jpg','gif','png');
		//check if allowed extension
		if(in_array($ext,$allowed_ext)){


		}else{
			$error="File Type Not Allowed!";
		}

	}else{
		$error="No File Uploaded!";
	}

if (!isset($error)){
	$mailcontent="<table width=100% border=0 cellpadding=4 cellspacing=0 bgcolor=#000000 >";
	$mailcontent.="<tr><td valign=top><table width=710 cellpadding=0 cellspacing=0 border=0 bordercolor=#FFFFFF>";
	$mailcontent.="<tr><td colspan=2 ><font size=3 face=Verdana, Arial, Helvetica, sans-serif color=#FFFFFF><strong>Walpole Group Male Application Form</strong></font><br></td><td> </td></tr>";
	$mailcontent.="</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>";
	//======================model contact info=======================================

	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Model's Information</b></font></td><td> </td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Stage Name:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["stageName"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>First Name:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["firstName"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Surname:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["surName"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>N I No:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["niNo"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Date of birth:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["dob"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Age:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["age"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Star sign:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["star"])." </font></td><td> </td>";

	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 1:</font></td>";
	$mailcontent.="<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address1"])." </font></td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 2:</font></td>";
	$mailcontent.="<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address2"])." </font></td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Address 3:</font></td>";
	$mailcontent.="<td width = 201 colspan=2><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["address3"])." </font></td>";

	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Town/City:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["town"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Postcode:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["postcode"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>States:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["states"])." </font></td><td> </td>";

	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Home Telephone No:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["homeNo"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Mobile Telephone No:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["mobileNo"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Email Address:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["email"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Web Address:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["webAddress"])." </font></td><td> </td>";

	//=====================model physical info========================================

	$mailcontent.="</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Physical Descriptions</b></font></td><td> </td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Height:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["height"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Weight:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["weight"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Suit size:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["suitSize"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Shoe size:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["shoeSize"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Chest size:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["chestSize"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Waist Size:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["waistSize"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Leg Size:</font></td>";

	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["legSize"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Hair color:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["hairColor"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Length:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["length"])." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Eyes color:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["eyesColor"])." </font></td><td> </td>";

	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Complexion:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["complexion"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Ethnic origin:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["ethnicOrigin"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Other info:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Do you smoke:".$comDisplay12."<BR>Do you drink:".$comDisplay13."<BR>Do you drive:".$comDisplay14."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Piercings:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".$comDisplay16." </font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Tattoos:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".$comDisplay17." </font></td><td> </td>";
	//======================model attributes==============================================

	$mailcontent.="</tr><tr><td colspan=3><hr align=center width=100% size=1 noshade color=#3C4B86></td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif><b>Model's attributes</b></font></td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Work undertaken</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Fashion:".$comDisplay18."</td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Swimwear:".$comDisplay19."</td></font></tr> ";
	$mailcontent.="<tr><td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Nude:".$comDisplay20."</font></td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Boy / Girl Soft:".$comDisplay21."</font></td></tr>";
	$mailcontent.="<tr><Td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Boy / Girl XXX:".$comDisplay21a."</font></td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Stills:".$comDisplay22."</font></td></tr>";
	$mailcontent.="<tr><Td> </td><td><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Video:".$comDisplay23."</font></td><td> </td></tr>";

	$mailcontent.="</tr><tr><td width=201> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Previous experiences:</font></td>";
	$mailcontent.="<td colspan=2 width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["experience"])." </font></td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Introduce By:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["introduceBy"])."</font></td><td> </td>";
	$mailcontent.="</tr><tr><td width=201 valign=top> <font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>Date:</font></td>";
	$mailcontent.="<td width = 201><font color=#CCCCCC size=2 face=Verdana, Arial, Helvetica, sans-serif>".trim($_POST["dateTime"])."</font></td><td> </td>";

	//======================model related info============================================

	$mailcontent.="</tr><tr><td colspan=3> </td></tr></table>";

	$mail_content="<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\"><html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head><body><center>$mailcontent</center></body></html>";		
			$eol="\r\n";
			$file=$tmp_name;
			$content=chunk_split(base64_encode(file_get_contents($file)));
			$uid= md5(uniqid(time()));

			$headers = "From: $from".$eol;
			$headers .= "X-Sender: $from".$eol;
			$headers .= "X-Priority: 3".$eol;
			$headers .= "X-Mailer: php".$eol;   

			//declarinf mutlipart boundary type
			$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$uid."\"".$eol.$eol;
	        $headers .= "this is a message in multipart MIME format.".$eol.$eol;


				$headers .= "--PHP-mixed-".$uid."".$eol; 
			$headers .= "Content-Type: multipart/alternative; boundary=\"PHP-alt-".$uid."\"".$eol.$eol;
			$headers .= "--PHP-alt-".$uid."".$eol;  
			$headers .= "Content-type: text/html; charset=utf-8".$eol;
	        $headers .= "Content-Transfer-Encoding: 7bit".$eol.$eol;   
	        $headers .= "$mail_content".$eol.$eol; 
			$headers .= "--PHP-alt-".$uid."--".$eol;  

	        //file attachment
	        $headers .= "--PHP-mixed-".$uid."".$eol;
		 $headers .= "Content-Type: application/octet-stream; name=\"".$file_name."\"".$eol; // use different content types here
			$headers.="Content-Transfer-Encoding: base64".$eol;
			$headers.="Content-Disposition: attachment; filename=\"".$file_name."\"".$eol;

			$headers.=$content."".$eol.$eol;
	        $headers .= "--PHP-mixed-".$uid."--";	
		   	$mail_content="";

	mail($to, $subject, $mail_content, $headers);
	header("Location: thankyou.php");
	exit;

}
}?>

Link to comment
Share on other sites

	$headers = "From: $from".$eol;
$headers .= "X-Sender: $from".$eol;
$headers .= "X-Priority: 3".$eol;
$headers .= "X-Mailer: php".$eol;   

//declarinf mutlipart boundary type
$headers .= "Content-Type: multipart/mixed; boundary=\"PHP-mixed-".$uid."\"".$eol.$eol;
$headers .= "this is a message in multipart MIME format.".$eol.$eol;


$headers .= "--PHP-mixed-".$uid."".$eol; 
$headers .= "Content-Type: multipart/alternative; boundary=\"PHP-alt-".$uid."\"".$eol.$eol;
$headers .= "--PHP-alt-".$uid."".$eol;  
$headers .= "Content-type: text/html; charset=utf-8".$eol;
$headers .= "Content-Transfer-Encoding: 7bit".$eol.$eol;   
$headers .= "$mail_content".$eol.$eol; 
$headers .= "--PHP-alt-".$uid."--".$eol;  

//file attachment
$headers .= "--PHP-mixed-".$uid."".$eol;
$headers .= "Content-Type: application/octet-stream; name=\"".$file_name."\"".$eol; // use different content types here
$headers.="Content-Transfer-Encoding: base64".$eol;
$headers.="Content-Disposition: attachment; filename=\"".$file_name."\"".$eol;

$headers.=$content."".$eol.$eol;
$headers .= "--PHP-mixed-".$uid."--";	
$mail_content="";

 

Content-Type: multipart/mixed; boundary="PHP-mixed-XXXXXX" is a header. Everything else you are putting into $headers after that line is the body of the message. Strictly speaking, the "headers" end when a blank line is found (which is indicated by the $eol . $eol in your code). However, as the PHP mail() function does it's job, it may be adding other header stuff and that may be breaking your structure. It does, after all, have to add the To: and Subject: headers.

 

I'm not sure if you need the extra EOLs you are putting inside the multi-part message (the part I just told you to move out of the headers), I don't think you do. And that may break the base64 encoding (I doubt it, but I would check).

 

Since mail clients are like browsers, in that they seem to make up their own rules for interpreting the content; you should always get as close as you can to the specifications. Or install every mail client known to man and test all of your emails.

Link to comment
Share on other sites

it works with GMail/AOL/MSN/hotmail and most POP clients.

 

 

 

do you think microsoft outlook would recognize it if i added there MIME header for PGB S/mime certificate?

 

 

and how would i addd it into the current header?

 

http://wildness.espix.org/index.php?post/2012/04/30/Sending-PGP-HTML-Encrypted-e-mail-with-PHP

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.