Jump to content

Error with mail() has me scratching my head?


amites

Recommended Posts

I'm attempting to fix someones script

 

the end of it uses an email class to send off a message with attachment, when I run it I get

 

 

Warning:  mail(): Bad parameters to mail() function, mail not sent. in /home/content/h/o/t/hotjobs/html/eden/test/return.php on line 1248

 

line 1248 looks like

 

mail($this->mailTo,$this->mailSubject,"",$mailHeader);

 

simple enough,

 

the data being passed to it:

 

$this->mailTo = paypal_1212457747_per@mitesdesign.com

 

$this->mailSubject = FREE ALCOHOL RECIPES

 

and $mailHeader gets rather long, so I'll ask here

 

any ideas?

 

FROM: staff@starbay.com
Content-Type: multipart/mixed;
boundary="----ed81347417ad3f673101803677e6b160"

This is a multi-part message in MIME format.
------ed81347417ad3f673101803677e6b160
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----19a417732b7030a475ce241574f12466"


------19a417732b7030a475ce241574f12466
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit



HOW TO MAKE YOUR OWN HOME BREW. This report is presented as information only. The author is not responsible if this recipe is so pleasing that you drink the brew excessively. The necessary ingredients are usually available from most markets, and the bottle capper and caps may be found at most hardware stores. You will also need a crock, about 10 gallons and a hydrometer of the type designed for brewing. The purpose of the hydrometer is to determine when the sugar content of the mix is less than 1%. It will float on top of the mix for about 3 or 4 days, and when it sinks you are ready to bottle the brew. You will need a collection of empty bottles - the quart size is best. Be sure they are SUPER clean. Ingredients: Malt-2 cups, Sugar-5 cups, Yeast-1 tbsp,Water-3 gallons. For a darker color add more malt. For stronger flavor add more sugar and a small amount of brewer's hops. The BEST flavor, at least to the author is to use 3 cups of superfine sugar and 3 cups of brown sugar. This gives about 18% by volume - 36 proof. Heat about 2 quarts of water and dissolve the malt syrup. Add the sugar to the mix slowly and stir until dissolved. Let the mix boil for several minutes then pour into crock and add the balance of water. If you use hops wrap them in a cheese cloth and hang it in the mix. Wait about three hours and skim off foam. Place the hydrometer in the mix and from this point on keep your eye on it. It will sink in about three days or so and you are ready to bottle. The best way to bottle is a small siphon hose. Try NOT to disturb the mix. Slowly place the hose about one inch from the bottom and start the siphon action. As each bottle is filled about one inch from the top, pinch the hose to stop the flow and then release and fill the next bottles and let them age - at least 10 days and 30 days is better. The very best flavor comes after about 3 months. If you are smart - start another batch immediately as you will want to start drinking the first one almost immediately. And remember - Don t Blame Me If You Drink Too Much!

How To Make Alcohol............................ go here for still.

http://www.jerryeden.com/still/ST45526918.html

Please download and PRINT your plans ASAP, as we are going to password protect the page.

Thank You

Staff

------19a417732b7030a475ce241574f12466--
------ed81347417ad3f673101803677e6b160
Content-Type: application/octet-stream;
name="Liqueur%20Recipes.doc"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="Liqueur%20Recipes.doc"

IEplbGwtTyB3aXRoIFZvZGthIGluIGl0IA0NICAgICAxLiBSdW4gdG8gdGhlIHN0b3JlIGFuZCBi
dXkgeW91cnNlbGYgYSBnb29kIHN1cHBseSBvZiBwbGFzdGljIHNob3QNICAgICAgICAgICAgICAg
ICAgICAgICAgZ2xhc3NlcyBvciBzbWFsbCBEaXhpZSBjdXBzIHdpbGwgZG8uDSAgICBCZWZvcmUg
eW91IGxlYXZlIHRoZSBzdG9yZSwgYnV5IGEgZmV3IGJveGVzIG9mIHlvdXIgZmF2b3JpdGUgZmxh
dm9ycw0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBvZiBKZWxsLU8uIA0N
ICAgICAgICAgICAgICAgICAgIDIuIFBpY2sgdXAgYSBib3R0bGUgb2YgeW91ciBmYXZvcml0ZSB2
b2RrYS4gDQ0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIDMuIE9uY2UgeW91IGdldCBo
b21lLA0gICAgICAgICAgICAgICAgICAgIGJvaWwgc29tZSB3YXRlciB0byBtYWtlIHRoZSBKZWxs
LU8gd2l0aC4NDSAgICA0LiBBcnJhbmdlIHRoZSBzaG90IGdsYXNzZXMgb3IgRGl4aWUgY3VwcyBv
biBhIHRyYXkgdGhhdCB5b3UgY2FuIGZpdA0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
aW50byB5b3VyIHJlZnJpZ2VyYXRvci4gDQ0gICAgIDUuIEdldCBhIG1lYXN1cmluZyBjdXAgYW5k
IHBvdXIgaW4gb25lIGN1cCBvZiBib2lsaW5nIHdhdGVyIGludG8NICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgYSBtaXhpbmcgYm93bC4gDSAgICBQb3VyIHRoZSB3YXRlciBpbnRv
IHRoZSBib3dsIHdpdGggb25lIGJveCBvZiBKZWxsLU8gcG93ZGVyIGluIGl0Lg0gICAgICAgICAg
U3RpciB0aGUgY29udGVudHMgdGlsbCB0aGUgcG93ZGVyIGlzIGNvbXBsZXRlbHkgZGlzc29sdmVk
Lg0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFNldCBhc2lkZSB0aWxsIGNvb2wu
DSAgICAgICAgICAgICAgKGlmIGl0cyBob3QgdGhlIGFsY29ob2wgd2lsbCBldmFwb3JhdGUgZnJv
bSB0aGUgamVsbG8pDQ0gICAgICAgIDYuIE1lYXN1cmUgb3V0IG9uZSBjdXAgb2Ygdm9ka2EgYW5k
IHBvdXIgaXQgaW50byB0aGUgbGlxdWlkDSAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
ICAgICAgICAgSmVsbC1PLg0gICAgICAgICAgICAgICAgTWFrZSBzdXJlIHRvIG1peCB3ZWxsLiBQ
b3VyIGludG8gdGhlIHNob3QgY3Vwcy4NDSAgICA3LiBQb3VyIHRoZSBtaXh0dXJlIGludG8gdGhl
IGN1cHMgc28gdGhhdCB0aGV5IGFyZSBhYm91dCAxLzIgdG8gMy80DSAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICBmdWxsLg0gICAgICAgICAgICAgICAgICAgUHV0IHRo
ZSB0cmF5IG9mIHNob3RzIGludG8gdGhlIHJlZnJpZ2VyYXRvci4gDSAgICAgICAgICAgICAgICAg
ICAgIEFsbG93IHRoZSBtaXh0dXJlIGVub3VnaCB0aW1lIHRvIHNldC4gDSAgICBSRU1FTUJFUjog
V2l0aCBWb2RrYSBpbiB0aGUgbWl4dHVyZSBpdCB3aWxsIHRha2UgbG9uZ2VyIHRoYW4NICAgICAg
ICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1c3VhbCB0byBzZXQuIA0gICAgICAgICAg
ICAgICAgICAgICAgICAgIFByb3ZpZGUgc3Bvb25zIHRvIHlvdXIgZ3Vlc3RzLiANICAgICBJZiB5
b3UgZmVlbCBsaWtlIGJlaW5nIGNyZWF0aXZlIHlvdSBjYW4gcHV0IGEgbGl0dGxlIHdoaXBwZWQg
Y3JlYW0NICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIG9uIHRvcCBvZiB0aGUgc2hv
dC4NDSAgICAgICAgICAgICAgICAgUmVtZW1iZXI6IFRoZXJlIGlzIGFsd2F5cyByb29tIGZvciBK
ZWxsLU8hIA0NICAgICAgICAgICAgICAgICAgICAgICAgICAgICBBIGdyZWF0IHZhcmlhdGlvbiBp
cyB0byB1c2UgDSAgICAgICAgICAgICAgICAgICAgICAgICBUZXF1aWxhIGFuZCBsZW1vbiBvciBs
aW1lIEplbGxvDQ0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIFF1aWNrIGhp
bnQ6IA0gICAgICB0ZXN0IHRoZSBzdHJlbmd0aCBvZiB0aGUgbWl4dHVyZSBiZWZvcmUgeW91IGdv
IGNyYXp5IG1ha2luZyA1MA0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRv
ei4gb2YgdGhlc2UuDSAgICAgVGhlcmUgaXMgcmVhbGx5IG5vdGhpbmcgbW9yZSB1bi1wbGVhc2Fu
dCB0aGFuIGEgSmVsbC1PIHNob3QgdGhhdA0gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAg
dGFzdGVzIGxpa2UgcHVyZSBWb2RrYS4NICAgICAgICAgICAgIFVubGVzcyB5b3UgbGlrZSB0aGF0
IHRhc3RlIGFuZCBpbiB0aGF0IGNhc2UgaXQncyBPa2F5LiANDQ0NDQ0gICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICBSdXNzaWFuIFF1YWFsdWRlIA0NICAgICAgICAgICAgICAgICAgICAgICAg
ICBUaGlzIHF1YWFsdWRlIGlzIG5vdCBvbmx5IGxlZ2FsLA0gICAgICAgICAgICAgICAgICAgYnV0
IGEgcmF0aGVyIHBsZWFzYW50IHdheSB0byBwYXNzIHRoZSB0aW1lLg0gICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgVGFrZSBhIHJvY2tzIGdsYXNzLA0gICAgICAgICAgICAgICAgICAg
ICAgICAgICAgICAgICAgICAgYWRkIHRoZSByb2NrcywNICAgICBwb3VyIGluIGVxdWFsIHBhcnRz

this goes on for a while...

bmQgbm90IHRvIHlpZWxkLg0NDQ1FTkpPWSEhISE=
------ed81347417ad3f673101803677e6b160--

Link to comment
Share on other sites

thank you,

 

I'd still like to figure out why this isn't working as it was supposedly working on a previous server (so I was told) currently on GoDaddy

 

 

if it can help anyone this is the class I'm working with

 

/*******************************************************************************
Name:			Email
Description:	This class is used for sending emails.
		These emails can be
		Plain Text, HTML, or Both. Other uses include file
		Attachments and email Templates(from a file).
Testing:
	test_email.php3:

	$mail->setTo("myEmail@yo.com");
	$mail->send();


Changelog:
Date		Name			Description
----------- ----------- 	------------------------------------------------
10/21/1999	R.Chambers		created
10/31/2002	W. Ladd		encode() added for WINDOWS as a replacement
				for UUENCODE

				send() enhanced to recognize combination of Text
				and Atachment

				formatAttachmentHeader() (64 bit encoding).  Line
				building loop limit changed to <= element count.
                                        This picks up the last line of the encoded attachment
*******************************************************************************/
/*******************************************************************************
Issues:
	no error reporting
	can only send HTML with TEXT
	can only send attachements with HTML and TEXT
*******************************************************************************/
/*******************************************************************************
Function Listing:
	setTo($inAddress)
	setCC($inAddress)
	setBCC($inAddress)
	setFrom($inAddress)
	setSubject($inSubject)
	setText($inText)
	setHTML($inHTML)
	setAttachments($inAttachments)
	checkEmail($inAddress)
	loadTemplate($inFileLocation,$inHash,$inFormat)
	getRandomBoundary($offset)
	getContentType()
	formatTextHeader()
	formatHTMLHeader()
	formatAttachmentHeader($inFileLocation)
	send()
*******************************************************************************/

class Email
{
//---Global Variables
var $mailTo				= "";						// array of To addresses
var $mailCC				= "";						// copied recipients
var $mailBCC			= "";						// hidden recipients
var $mailFrom			= "";						// from address
var $mailSubject		= "";					// email subject
var $mailText			= "";						// plain text message
var $mailHTML			= "";						// html message
var $mailAttachments	= "";				// array of attachments

/*******************************************************************************
Function:		setTo($inAddress)
Description:	sets the email To address
Arguments:		$inAddress as string
				separate multiple values with comma
Returns:		true if set
*******************************************************************************/
function setTo($inAddress){
	//--split addresses at commas
	$addressArray = explode(",",$inAddress);
	//--loop through each address and exit on error
	for($i=0;$i<count($addressArray);$i++){
		if($this->checkEmail($addressArray[$i])==false) return false;
	}
	//--all values are OK so implode array into string
	$this->mailTo = implode($addressArray,",");
	return true;
}
/*******************************************************************************
Function:		setCC($inAddress)
Description:	sets the email cc address
Arguments:		$inAddress as string
				separate multiple values with comma
Returns:		true if set
*******************************************************************************/
function setCC($inAddress){
	//--split addresses at commas
	$addressArray = explode(",",$inAddress);
	//--loop through each address and exit on error
	for($i=0;$i<count($addressArray);$i++){
		if($this->checkEmail($addressArray[$i])==false) return false;
	}
	//--all values are OK so implode array into string
	$this->mailCC = implode($addressArray,",");
	return true;
}
/*******************************************************************************
Function:		setBCC($inAddress)
Description:	sets the email bcc address
Arguments:		$inAddress as string
				separate multiple values with comma
Returns:		true if set
*******************************************************************************/
function setBCC($inAddress){
	//--split addresses at commas
	$addressArray = explode(",",$inAddress);
	//--loop through each address and exit on error
	for($i=0;$i<count($addressArray);$i++){
		if($this->checkEmail($addressArray[$i])==false) return false;
	}
	//--all values are OK so implode array into string
	$this->mailBCC = implode($addressArray,",");
	return true;
}
/*******************************************************************************
Function:		setFrom($inAddress)
Description:	sets the email FROM address
Arguments:		$inAddress as string (takes single email address)
Returns:		true if set
*******************************************************************************/
function setFrom($inAddress){
	if($this->checkEmail($inAddress)){
		$this->mailFrom = $inAddress;
		return true;
	}
	return false;
}
/*******************************************************************************
Function:		setSubject($inSubject)
Description:	sets the email subject
Arguments:		$inSubject as string
Returns:		true if set
*******************************************************************************/
function setSubject($inSubject){
	if(strlen(trim($inSubject)) > 0){
		$this->mailSubject = ereg_replace("\n","",$inSubject);
		return true;
	}
	return false;
}
/*******************************************************************************
Function:		setText($inText)
Description:	sets the email text
Arguments:		$inText as string
Returns:		true if set
*******************************************************************************/
function setText($inText){
	if(strlen(trim($inText)) > 0){
		$this->mailText = $inText;
		return true;
	}
	return false;
}
/*******************************************************************************
Function:		setHTML($inHTML)
Description:	sets the email HMTL
Arguments:		$inHTML as string
Returns:		true if set
*******************************************************************************/
function setHTML($inHTML){
	if(strlen(trim($inHTML)) > 0){
		$this->mailHTML = $inHTML;
		return true;
	}
	return false;
}
/*******************************************************************************
Function:		setAttachments($inAttachments)
Description:	stores the Attachment string
Arguments:		$inAttachments as string with directory included
				separate multiple values with comma
Returns:		true if stored
*******************************************************************************/
function setAttachments($inAttachments){
	if(strlen(trim($inAttachments)) > 0){
		$this->mailAttachments = $inAttachments;
		return true;
	}
	return false;
}
/*******************************************************************************
Function:		checkEmail($inAddress)
Description:	checks for valid email
Arguments:		$inAddress as string
Returns:		true if valid
*******************************************************************************/
function checkEmail($inAddress){
	return (ereg( "^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|net|com|gov|mil|org|edu|int)\$",$inAddress));
}


/*******************************************************************************
Function:		Encode($inFileLocation)
Description:		reads an attachment file and encodes it as MIME compliant base64
Arguments:		$inFileLocation as string with relative directory

Returns:		array of encoded strings (each 76 bytes long)
*******************************************************************************/

	function Encode($inFileLocation){
	if($myFile = fopen($inFileLocation,"rb")){
		//--loop through file, line by line
		$i = 1;
		while(!feof($myFile)):
			//--get 57 chars until eof
			$myLine = fread($myFile,57);
                                //-- each 57 byte string will return a 76 byte encoded string
			$encoded[$i] = base64_encode($myLine);
			$i++;

		endwhile;
		//--close file
		fclose($myFile);
		//--set Mail body to proper format
		return ($encoded);
	}
	return false;
}







/*******************************************************************************
Function:		loadTemplate($inFileLocation,$inHash,$inFormat)
Description:	reads in a template file and replaces hash values
Arguments:		$inFileLocation as string with relative directory
				$inHash as Hash with populated values
				$inFormat as string either "text" or "html"
Returns:		true if loaded
*******************************************************************************/

	function loadTemplate($inFileLocation,$inHash,$inFormat){
	/*
	template files have lines such as:
		Dear ~!UserName~,
		Your address is ~!UserAddress~
	*/
	//--specify template delimeters
	$templateDelim = "~";
	$templateNameStart = "!";
	//--set out string
	$templateLineOut = "";
	//--open template file
	if($templateFile = fopen($inFileLocation,"r")){
		//--loop through file, line by line
		while(!feof($templateFile)){
			//--get 1000 chars or (line break internal to fgets)
			$templateLine = fgets($templateFile,1000);
			//--split line into array of hashNames and regular sentences
			$templateLineArray = explode($templateDelim,$templateLine);
			//--loop through array
			for( $i=0; $i<count($templateLineArray);$i++){
				//--look for $templateNameStart at position 0
				if(strcspn($templateLineArray[$i],$templateNameStart)==0){
					//--get hashName after $templateNameStart
					$hashName = substr($templateLineArray[$i],1);
					//--replace hashName with acual value in $inHash
					//--(string) casts all values as "strings"
					$templateLineArray[$i] = ereg_replace($hashName,(string)$inHash[$hashName],$hashName);
				}
			}
			//--output array as string and add to out string
			$templateLineOut .= implode($templateLineArray,"");
		}
		//--close file
		fclose($templateFile);
		//--set Mail body to proper format
		if( strtoupper($inFormat)=="TEXT" ) return($this->setText($templateLineOut));
		else if( strtoupper($inFormat)=="HTML" ) return($this->setHTML($templateLineOut));
	}
	return false;
}
/*******************************************************************************
Function:		getRandomBoundary($offset)
Description:	returns a random boundary
Arguments:		$offset as integer - used for multiple calls
Returns:		string
*******************************************************************************/
function getRandomBoundary($offset = 0){
	//--seed random number generator
	srand(time()+$offset);
	//--return md5 32 bits plus 4 dashes to make 38 chars
	return ("----".(md5(rand())));
}
/*******************************************************************************
Function:		getContentType($inFileName)
Description:	returns content type for the file type
Arguments:		$inFileName as file name string (can include path)
Returns:		string
*******************************************************************************/
function getContentType($inFileName){
	//--strip path
	$inFileName = basename($inFileName);
	//--check for no extension
        if(strrchr($inFileName,".") == false){
		return "application/octet-stream";
	}
	//--get extension and check cases
        $extension = strrchr($inFileName,".");
        switch($extension){
		case ".gif":	return "image/gif";
		case ".gz":		return "application/x-gzip";
            case ".htm":	return "text/html";
            case ".html":	return "text/html";
            case ".jpg":	return "image/jpeg";
            case ".tar":	return "application/x-tar";
		case ".txt":	return "text/plain";
            case ".zip":    return "application/zip";
            default:		return "application/octet-stream";
        }
	return "application/octet-stream";
}
/*******************************************************************************
Function:		formatTextHeader
Description:	returns a formated header for text
Arguments:		none
Returns:		string
*******************************************************************************/
function formatTextHeader(){
	$outTextHeader = "";
	$outTextHeader .= "Content-Type: text/plain; charset=us-ascii\n";
	$outTextHeader .= "Content-Transfer-Encoding: 7bit\n\n";
	$outTextHeader .= $this->mailText."\n";
	return $outTextHeader;
}
/*******************************************************************************
Function:		formatHTMLHeader
Description:	returns a formated header for HTML
Arguments:		none
Returns:		string
*******************************************************************************/
function formatHTMLHeader(){
	$outHTMLHeader = "";
	$outHTMLHeader .= "Content-Type: text/html; charset=us-ascii\n";
	$outHTMLHeader .= "Content-Transfer-Encoding: 7bit\n\n";
	$outHTMLHeader .= $this->mailHTML."\n";
	return $outHTMLHeader;
}
/*******************************************************************************
Function:		formatAttachmentHeader($inFileLocation)
Description:	returns a formated header for an attachment
Arguments:		$inFileLocation as string with relative directory
Returns:		string
*******************************************************************************/
function formatAttachmentHeader($inFileLocation){
	$outAttachmentHeader = "";
	//--get content type based on file extension
	$contentType = $this->getContentType($inFileLocation);
	//--if content type is TEXT the standard 7bit encoding
	if(ereg("text",$contentType)){
		//--format header
		$outAttachmentHeader .= "Content-Type: ".$contentType.";\n";
		$outAttachmentHeader .= ' name="'.basename($inFileLocation).'"'."\n";
		$outAttachmentHeader .= "Content-Transfer-Encoding: 7bit\n";
		$outAttachmentHeader .= "Content-Disposition: attachment;\n";	//--other: inline
		$outAttachmentHeader .= ' filename="'.basename($inFileLocation).'"'."\n\n";
		$textFile = fopen($inFileLocation,"r");
		//--loop through file, line by line
		while(!feof($textFile)){
			//--get 1000 chars or (line break internal to fgets)
			$outAttachmentHeader .= fgets($textFile,1000);
		}
		//--close file
		fclose($textFile);
		$outAttachmentHeader .= "\n";
	}
	//--NON-TEXT use 64-bit encoding
	else{
		//--format header
		$outAttachmentHeader .= "Content-Type: ".$contentType.";\n";
		$outAttachmentHeader .= ' name="'.basename($inFileLocation).'"'."\n";
		$outAttachmentHeader .= "Content-Transfer-Encoding: base64\n";
		$outAttachmentHeader .= "Content-Disposition: attachment;\n";	//--other: inline
		$outAttachmentHeader .= ' filename="'.basename($inFileLocation).'"'."\n\n";

		/* UNIX -- use uuencode */
		//--call uuencode - output is returned to the return array
		//exec("uuencode -m $inFileLocation nothing_out",$returnArray);

		/* WINDOWS -- use ENCODE function -- */
		$returnArray = $this->Encode($inFileLocation);

		//--add each line returned
		for ($i = 1; $i<=(count($returnArray)); $i++){
			$outAttachmentHeader .= $returnArray[$i]."\n";
		}
	}
	return $outAttachmentHeader;
}
/*******************************************************************************
Function:		send()
Description:	sends the email
Arguments:		none
Returns:		true if sent
*******************************************************************************/
function send(){
	//--set  mail header to blank
	$mailHeader = "";
	//--add CC
	if($this->mailCC != "") $mailHeader .= "CC: ".$this->mailCC."\n";
	//--add BCC
	if($this->mailBCC != "") $mailHeader .= "BCC: ".$this->mailBCC."\n";
	//--add From
	if($this->mailFrom != "") $mailHeader .= "FROM: ".$this->mailFrom."\n";

	//---------------------------MESSAGE TYPE-------------------------------
	//--TEXT ONLY
	if($this->mailText != "" && $this->mailHTML == "" && $this->mailAttachments == ""){

		mail($this->mailTo,$this->mailSubject,$this->mailText,$mailHeader);
		//debug mail header
		return $mailHeader;
	}
	//--HTML AND TEXT
	else if($this->mailText != "" && $this->mailHTML != "" && $this->mailAttachments == ""){
		//--get random boundary for content types
		$bodyBoundary = $this->getRandomBoundary();
		//--format headers
		$textHeader = $this->formatTextHeader();
		$htmlHeader = $this->formatHTMLHeader();
		//--set MIME-Version
		$mailHeader .= "MIME-Version: 1.0\n";
		//--set up main content header with boundary
		$mailHeader .= "Content-Type: multipart/alternative;\n";
		$mailHeader .= ' boundary="'.$bodyBoundary.'"';
		$mailHeader .= "\n\n\n";
		//--add body and boundaries
		$mailHeader .= "--".$bodyBoundary."\n";
		$mailHeader .= $textHeader;
		$mailHeader .= "--".$bodyBoundary."\n";
		//--add html and ending boundary
		$mailHeader .= $htmlHeader;
		$mailHeader .= "\n--".$bodyBoundary."--";
		//--send message

		mail($this->mailTo,$this->mailSubject,"",$mailHeader);
		//debug mail header
		return $mailHeader;
	}
	//--HTML AND TEXT AND ATTACHMENTS
	else if($this->mailText != "" && $this->mailHTML != "" && $this->mailAttachments != ""){


		//--get random boundary for attachments
		$attachmentBoundary = $this->getRandomBoundary();
		//--set main header for all parts and boundary
		$mailHeader .= "Content-Type: multipart/mixed;\n";
		$mailHeader .= ' boundary="'.$attachmentBoundary.'"'."\n\n";
		$mailHeader .= "This is a multi-part message in MIME format.\n";
		$mailHeader .= "--".$attachmentBoundary."\n";

		//--TEXT AND HTML--
		//--get random boundary for content types
		$bodyBoundary = $this->getRandomBoundary(1);
		//--format headers
		$textHeader = $this->formatTextHeader();
		$htmlHeader = $this->formatHTMLHeader();
		//--set MIME-Version
		$mailHeader .= "MIME-Version: 1.0\n";
		//--set up main content header with boundary
		$mailHeader .= "Content-Type: multipart/alternative;\n";
		$mailHeader .= ' boundary="'.$bodyBoundary.'"';
		$mailHeader .= "\n\n\n";
		//--add body and boundaries
		$mailHeader .= "--".$bodyBoundary."\n";
		$mailHeader .= $textHeader;
		$mailHeader .= "--".$bodyBoundary."\n";
		//--add html and ending boundary
		$mailHeader .= $htmlHeader;
		$mailHeader .= "\n--".$bodyBoundary."--";
		//--send message
		//--END TEXT AND HTML

		//--get array of attachment filenames
		$attachmentArray = explode(",",$this->mailAttachments);
		//--loop through each attachment
		for($i=0;$i<count($attachmentArray);$i++){
			//--attachment separator
			$mailHeader .= "\n--".$attachmentBoundary."\n";
			//--get attachment info
			$mailHeader .= $this->formatAttachmentHeader($attachmentArray[$i]);
		}
		$mailHeader .= "--".$attachmentBoundary."--";

		mail($this->mailTo,$this->mailSubject,"",$mailHeader);
            //debug mail header
            return $mailHeader;
            	}
	//TEXT AND ATTACHMENTS
	else if($this->mailText != ""  && $this->mailAttachments != ""){

		//--get random boundary for attachments
		$attachmentBoundary = $this->getRandomBoundary();
		//--set main header for all parts and boundary
		$mailHeader .= "Content-Type: multipart/mixed;\n";
		$mailHeader .= ' boundary="'.$attachmentBoundary.'"'."\n\n";
		$mailHeader .= "This is a multi-part message in MIME format.\n";
		$mailHeader .= "--".$attachmentBoundary."\n";

		//--TEXT AND Attachments
		//--get random boundary for content types
		$bodyBoundary = $this->getRandomBoundary(1);
		//--format headers
		$textHeader = $this->formatTextHeader();

		//--set MIME-Version
		$mailHeader .= "MIME-Version: 1.0\n";
		//--set up main content header with boundary
		$mailHeader .= "Content-Type: multipart/alternative;\n";
		$mailHeader .= ' boundary="'.$bodyBoundary.'"';
		$mailHeader .= "\n\n\n";
		//--add body and boundaries
		$mailHeader .= "--".$bodyBoundary."\n";
		$mailHeader .= $textHeader;

		$mailHeader .= "\n--".$bodyBoundary."--";
		//--send message
		//--END TEXT AND HTML

		//--get array of attachment filenames
		$attachmentArray = explode(",",$this->mailAttachments);
		//--loop through each attachment
		for($i=0;$i<count($attachmentArray);$i++){
			//--attachment separator
			$mailHeader .= "\n--".$attachmentBoundary."\n";
			//--get attachment info
			$mailHeader .= $this->formatAttachmentHeader($attachmentArray[$i]);
		}
		$mailHeader .= "--".$attachmentBoundary."--";

echo '<div>'.$this->mailTo ."<br><br>\n\n".$this->mailSubject."<br><br>\n\n".$mailHeader.'</div>';

		mail($this->mailTo,$this->mailSubject,"",$mailHeader);
		return $mailHeader;

	}
	return false;
}
}
/*========================================================================================*/
/* END OF EMAIL CLASS */
/*=======================================================================================*/

Link to comment
Share on other sites

Is everything on the loooong listing being placed into the Headers portion?

It's my understanding that Headers should only have one line break between each, and that most of the MIME/message stuff should probably be in the BODY portion, which is being left blank it looks like.

 

Looks curious to me.

Link to comment
Share on other sites

wow, why didn't I notice that before.  Yup, that'd be the problem.  Only headers go in headers, the mime body goes in the message body:

<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

example is from PHP.net

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.