Jump to content

Sent by: Apache <apache@server_name>


ScotDiddle

Recommended Posts

Gentlefolk,

 

When using the PHP mail function with Apache 2.2, the generated email shows the message indicated in the title of this post...  Above the message I find the text I coded as the "from" var.  Any ideas on how to suppress / change / delete said message ?

 

Thanks,

 

Scot L. Diddle, Richmond VA

 

Link to comment
https://forums.phpfreaks.com/topic/136496-sent-by-apache/
Share on other sites

thorpe,

 

  A little lenghty, but here it is...

  Thanks for looking at it.

 

Scot L. Diddle, Richmond VA

 


<?php

$myCapturedOutput = $smarty->fetch('HAZSPILL.html.tpl');

function mail_attachment($ExcelPath, $ExcelFilename, $CSVPath, $CSVFilename,  $mailto, $from_mail, $from_name, $replyto, $subject, $message) { 

		// This bad boy came from : http://www.webcheatsheet.com/PHP/send_email_text_html_attachment.php

	$uid = md5(uniqid(time()));

		if ($ExcelPath != "") {

		$ExcelFile = $ExcelPath . $ExcelFilename;
		$ExcelFile_size = filesize($ExcelFile);
		$ExcelHandle = fopen($ExcelFile, "r");
		$ExcelContent = fread($ExcelHandle, $ExcelFile_size);
		fclose($ExcelHandle);

		$ExcelContent = chunk_split(base64_encode($ExcelContent));

//			$CSVFile = $CSVPath . $CSVFilename;
//			$CSVFile_size = filesize($CSVFile);
//			$CSVHandle = fopen($CSVFile, "r");
//			$CSVContent = fread($CSVHandle, $CSVFile_size);
//			fclose($CSVHandle);
//	
//			$CSVContent = chunk_split(base64_encode($CSVContent));
//	
//			$name = basename($ExcelFile);

		}

	$header  = "From: ".$from_name." <".$from_mail.">\r\n";
	$header .= "Reply-To: ".$replyto."\r\n";

	$header .= "MIME-Version: 1.0\r\n";
	$header .= "Content-Type: multipart/mixed; boundary=".$uid."\r\n\r\n";
	$header .= "This is a multi-part message in MIME format.\r\n \n";

	if ($ExcelPath != "") {

		// Allow Attachments
		//$header .= "MIME-Version: 1.0\r\n";
		//$header .= "Content-Type: multipart/mixed; boundary=".$uid."\r\n\r\n";
		//$header .= "This is a multi-part message in MIME format.\r\n \n";


		// Here is the Excel Attachment
		$header .= "--".$uid."\r\n";
		$header .= "Content-Type: application/octet-stream; name=".$ExcelFilename."\r\n"; // use diff. types here 
		$header .= "Content-Transfer-Encoding: base64\r\n";
		$header .= "Content-Disposition: attachment; filename=".$ExcelFilename."\r\n\r\n";
		$header .= $ExcelContent."\r\n\r\n";


		// Here is the CSV Attachment
		// Defunct 10/20/2008
		// Tab and Double-quote delimited file worked better in MS Access...
//			$header .= "--".$uid."\r\n";
//			$header .= "Content-Type: application/text; name=".$CSVFilename."\r\n"; // use diff. types here 
//			$header .= "Content-Transfer-Encoding: base64\r\n";
//			$header .= "Content-Disposition: attachment; filename=".$CSVFilename."\r\n\r\n";
//			$header .= $CSVContent."\r\n\r\n";

	}

	// Here is the body
	$header .= "--".$uid."\r\n";
	$header .= "Content-type:text/html; charset=iso-8859-1\r\n";
	$header .= "Content-Transfer-Encoding: 7bit\r\n\r\n";
	$header .= $message."\r\n\r\n";

	$header .= "--".$uid."\r\n";

	if (mail($mailto, $subject, "", $header)) {
		return TRUE;
	}
	else {
			return FALSE;
	}


}

// $hazspillXLS = 'Hazspill.Test.csv'; // Was '.xls' 10/20/2008
// $hazspillCSV = 'Hazspill.Test.csv'; // Defunct ... Double-quote delimited files works
									   // better as csv than tab delimited file

// how to use
$userEmailString  = $_SESSION['POST']['userSuppliedEmailAddresses'];
$userEmailStringPieces = array();
$commaPresent = stristr($userEmailString, ',');

if ($commaPresent) {
	$userEmailStringPieces = explode(',', $userEmailString);
}
else {
	$userEmailStringPieces = explode(' ', $userEmailString);
}

if (is_array($userEmailStringPieces)) {
	foreach($userEmailStringPieces as $trimCandidateIn) {
		if ($trimCandidateIn != '' && $trimCandidateIn != ' ') {
			$trimCandidateOut[] = trim($trimCandidateIn);
		}
	}
}
else {
	$trimCandidateOut = $userEmailString;
}

$userEmailStringPieces = $trimCandidateOut;

if (is_array($userEmailStringPieces)) {

	$uniqueEmailAddresses  = array_unique($userEmailStringPieces);

	$emailAddr = array();

	foreach ($uniqueEmailAddresses as $emailCandidate) {

		$isFM = stristr($emailCandidate, 'FormsMaster');

		if (!$isFM) {

			$emailCandidateLen = strlen($emailCandidate);

			if ($emailCandidateLen != 0) {
				$emailAddr[] = $emailCandidate;
			}
		}

	}

	$uniqueEmailAddresses = $emailAddr;

	$recipients = implode(', ', $uniqueEmailAddresses);
}
else {
	$recipients = '';
}

//	if ($ExcelPath != "") {
//		$recipients = '[email protected], [email protected], ' . $recipients;
//	}
//	else {
//		$recipients = '[email protected], ' . $recipients;
//	}

// $PRONumberString  = $_SESSION['POST']['HZ_PRONumbersTextArea'];

$PRONumberString = $_SESSION['POST']['HZ_PRONumber'];	

$PRONumberString = trim($PRONumberString);

$PRONumberStringPieces = explode(' ', $PRONumberString); 
$countOfPRONumbers = count($PRONumberStringPieces);

if ($countOfPRONumbers > 1) {
	$proLiteral = 'PROs';
}
else {
	$proLiteral = 'PRO';
}

// $myCapturedOutput is tacked onto the END of $message...
if ($recipients != '') {
	$message   = '<br /><font color="red">***</font> <font color="blue">Sent under separate cover to: " ' . $recipients . ' " <font color="red">***</font></font><br />' . $myCapturedOutput;
}
else {
	$message   = '<br /><font color="red">***</font> <font color="blue">No additional recipients specified for this form  <font color="red">***</font></font><br />' . $myCapturedOutput;
}	

$ExcelPath = "UPGFData/Excel/Hazspill/";
$ExcelFile = $_SESSION['HZ_ExcelFileAttachmentName'];
// $CSVPath   = "UPGFData/CSV/Hazspill/";				// Defunct 10/20/2008
// $CSVFile   = $_SESSION['HZ_CSVFileAttachmentName'];	// Defunct 10/20/2008
$CSVPath   = '';
$CSVFile   = '';
$name      = "HAZSPILL";
$from      = "[email protected]"; 
$replyto   = "";
$subject   = "$proLiteral " . $PRONumberString;

if ($_SESSION['WriteFiles']) {
	$recipient = '[email protected],  ';
}
else {
	$recipient = '[email protected], ';
}

$recipientMail1 = $recipient;


$mailRC1 = mail_attachment($ExcelPath, $ExcelFile, $CSVPath, $CSVFile, $recipient, $from, $name, $replyto, $subject, $message);

$ExcelPath = "";
$ExcelFile = '';
$CSVPath   = "";
$CSVFile   = '';
$name      = "HAZSPILL";
$from      = "[email protected]"; 
$replyto   = "";
$subject   = "$proLiteral " . $PRONumberString;
$recipient = $recipients;
$recipientMail2 = $recipient;
// $message   = $myCapturedOutput;
$message   = '<br /><font color="red">***</font> <font color="blue">Sent under separate cover to: " [email protected] " <font color="red">***</font></font><br />' . $myCapturedOutput;

if ($recipient != '') {
	$mailRC2 = mail_attachment($ExcelPath, $ExcelFile, $CSVPath, $CSVFile, $recipient, $from, $name, $replyto, $subject, $message);
}

echo "<html> \n"; 
echo "<body onLoad='javascript:scroll(0,0);'> \n ";

if ($mailRC1) {  
	echo "The HAZSPILL form has been sent to: <br /><br /><ul>\"[email protected]\"</ul><br /></br /> \n ";  
} 
else {
	echo "The HAZSPILL form has NOT been sent to: <br /><br /><ul>\"[email protected]\"</ul><br /><h4><font color=\"red\">Please inform the Help Desk about this error...</font></h4> \n"; 
} 

if ($recipients != '') {

	if ($mailRC2) {  
		echo "The HAZSPILL form has been sent to: <br /><br /><ul>$recipients</ul><br /></br /> \n ";  
	} 
	else {
		echo "The HAZSPILL form has NOT been sent to: <br /><br /><ul>$recipients</ul><br /></br /><h4><font color=\"red\">Please inform the Help Desk about this error...</font></h4> \n"; 
	} 

}

echo "Click <a href='javascript: void(0);' onClick='goBack();' title='Click Here To Return to Webforms'>here </a> to return to WebForms...\n "; 


unset($_SESSION['POST']); 


/**
 * 
 *  "So long, and thanks for all of the fish"
 * 
 */

?>

Link to comment
https://forums.phpfreaks.com/topic/136496-sent-by-apache/#findComment-712498
Share on other sites

thorpe,

 

  In my code window, click in the scroll bar white area 5 times, and you will come to the following...

 

  It is internal to the "function mail_attachment( ..."

 

Scot

 

<?php

	if (mail($mailto, $subject, "", $header)) {
		return TRUE;
	}
	else {
			return FALSE;
	}

?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/136496-sent-by-apache/#findComment-712523
Share on other sites

Archived

This topic is now archived and is closed to further replies.

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