Avatar of jsuissa
jsuissa
Flag for United States of America asked on

PHP Sendmail Attachment Issues

This is a sample of our current e-mail script. There are about 10 forms that use it. Right now the form responses don't go to the correct e-mail box. We need to see if this can be confirmed as a client side issue or if you can fix it.
So fo rinstance a form set to go to resumes@firmnyc.com goes to wallstreet@firmnyc, but this does not happen when we test externally.

We are using sendmail on PHP to send the script, and mail is turned off on our Plesk server, because we only want our servers to handle their outgoing PHP form mail -- not incoming.

More importantly, I have attached our e-mail script with the company named changed out. That way you can review how we are handling our attachments.

Currently, our e-mails work everyhwere except on the client's e-mail. The attachements come in the body of the e-mail instead of attachments..

Most imprtantly, we're not looking to use premade classes!

Any example of their e-mails they receive is this:

From: info@firmnyc.com [mailto:info@firmnyc.com]
Sent: Friday, July 18, 2008 5:22 PM
To: Resumes
Subject: Resume Submittal

Content-Type: multipart/mixed;

boundary="Multipart_Boundary_xa481579a18a377af5f87ca03f4cfe9b9x"

Return-Path: root@firmnyc.com
X-OriginalArrivalTime: 18 Jul 2008 21:22:20.0203 (UTC) FILETIME=[5C9A47B0:01C8E91C]

This is a multi-part message in MIME format.

--Multipart_Boundary_xa481579a18a377af5f87ca03f4cfe9b9x
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Page: Submit Resume Page

Contact Name: Justin

Email: justin@liquidcomma.com

Comments/Messages: Hey Sharon,

Did some more updates to the code and wanted to send one more test before the weekend. I am able to get emails with working attachments in Yahoo, Gmail, and my personal hosting server. Please forward this email to Justin and let us know if the attachment is working. Thanks for the help.



--Multipart_Boundary_xa481579a18a377af5f87ca03f4cfe9b9x
Content-Type: application/octet-stream;
Content-Disposition: attachment;
filename="Bazile.doc"
Content-Transfer-Encoding: base64

0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAPgADAP7/CQAGAAAAAAAAAAAAAAABAAAAOwAAAAAA
AAAA

EAAAPQAAAAEAAAD+////AAAAADoAAAD/////////////////////////////////////////
EAAAPQAAAAEAAAD+////


All the content below is the actual Word doc, but it's shows up in the body of the e-mail. We have tested this and if you tkae the full e-mail and save the copy it does become a working Word doc.


Thanks in advance.

<?php
 
session_start();
 
$position = $_SESSION['position_group'];
$search_url = $_SESSION["PositionsSearchURL"];
 
if ($position == "") {
	$position == "none";
}
 
include 'config.php';
include 'opendb.php';
$groupstop  = "SELECT id, groupname, status FROM groups WHERE status = 1 ORDER BY groupname ASC";
$resulttop = mysql_query($groupstop);
$groups  = "SELECT id, groupname, email, status FROM groups WHERE groupname = '$position' AND status = 1";
$result1 = mysql_query($groups);
$industries  = "SELECT id, name, short, status FROM industries WHERE status = 1";
$result2 = mysql_query($industries);
$locations  = "SELECT id, city, state, status FROM locations WHERE status = 1";
$result3 = mysql_query($locations);
 
$rowgroup = mysql_fetch_array($result1);
 
$emailsend = "info@firmnyc.com";  //This email will be info@firmnyc.com
 
if(mysql_num_rows($result1) == 1) {
	$emailsend = $rowgroup["email"];
}
 
if (isset($_REQUEST['employers'])){
	$pagename = "Page: Employer Page" . "\r\n";
	$subject="Request To Talk To A Representative";
}
 
if (isset($_REQUEST['contact'])){
	$pagename = "Page: Contact Us Page" . "\r\n";
	$subject="Request To Talk To A Representative";
}
 
if (isset($_REQUEST['submit'])){
	$pagename = "Page: Submit Position Page" . "\r\n";
	$subject="Request To Talk To A Representative";
}
 
if (isset($_REQUEST['submitposition'])){
	$pagename = "Page: Submit Position Page" . "\r\n";
	$subject="Position Submittal";
}
 
if (isset($_REQUEST['submitresume'])){
	$pagename = "Page: Submit Resume Page" . "\r\n";
	$subject="Resume Submittal";
	$emailsend = "resumes@firmnyc.com"; //This email will be resumes@firmnyc.com
}
 
if (isset($_REQUEST['submitapply'])){
	$pagename = "Page: Apply For Position Page" . "\r\n";
	$subject="Application For Position \n\n";
	$search_flag = 1;
 
	$positionhead = "Position Applied For:\r\n";
	$email_title = "Title: " . $_SESSION["title"] . "\r\n";
	$email_date = "Date: " . $_SESSION["date"] . "\r\n";
	$email_industry = "Industry: " .  $_SESSION["industry"] . "\r\n";
	$email_term = "Term: " . $_SESSION["term"] . "\r\n";
	
	if ($_SESSION["category"] == 1) {
	$email_salarylow = "Salary Low: " . $_SESSION["salary_low"]."K". "\r\n";
	$email_salaryhigh = "Salary High: " . $_SESSION["salary_high"]."K". "\r\n";
	$email_bonus = "Bonus Eligible: " . $_SESSION["bonus"] . "\r\n";	
	}
	else {
	$email_salarylow = "";
	$email_salaryhigh = "";
	$email_bonus = "";
	}
	
	if ($_SESSION["category"] == 2) {
	$email_hourlylow = "Hourly Rate Low: " . $_SESSION["hourly_low"]."\HR"."\r\n";
	$email_hourlyhigh = "Hourly Rate High: " . $_SESSION["hourly_high"]. "\HR"."\r\n";
	}
	else {
	$email_hourlylow = "";
	$email_hourlyhigh = "";
	}
 
	$email_city = "City: " . $_SESSION["city"] . "\r\n";
	$email_state = "State: " . $_SESSION["state"] . "\r\n";
	$email_group = "Position Group: " . $_SESSION["position_group"] . "\r\n";
 
}
 
if (!($_REQUEST['name'] == "")){
$name=$_REQUEST['name'];
$nameprint="Name: $name" . "\r\n";
}
else {
$nameprint="";
}
 
if (!($_REQUEST['contactname'] == "")){
$contactname=$_REQUEST['contactname'];
$contactnameprint="Contact Name: $contactname" . "\r\n";
}
else {
$companynameprint="";
}
 
if (!($_REQUEST['companyname'] == "")){
$companyname=$_REQUEST['companyname'];
$companynameprint="Company Name: $companyname" . "\r\n";
}
else {
$companynameprint="";
}
 
if (!($_REQUEST['company'] == "")){
$company=$_REQUEST['company'];
$companyprint="Company: $company" . "\r\n";
}
else {
$companyprint="";
}
 
if (!($_REQUEST['phone'] == "")){
$phone=$_REQUEST['phone'];
$phoneprint="Phone: $phone" . "\r\n";
}
else {
$phoneprint="";
}
 
if (!($_REQUEST['phone1'] == "")){
$phone=$_REQUEST['phone1'];
$phoneprint="Phone: $phone" . "\r\n";
}
else {
$phoneprint="";
}
 
if (!($_REQUEST['email'] == "")){
$email=$_REQUEST['email'];
$emailprint="Email: $email" . "\r\n";
}
else {
$emailprint="";
}
 
if (!($_REQUEST['position_group'] == "")){
$position=$_REQUEST['position_group'];
$positionprint="Position: $position" . "\r\n";
}
else {
$positionprint="";
}
 
if (!($_REQUEST['industry'] == "")){
$industry=$_REQUEST['industry'];
$industryprint="Industry: $industry" . "\r\n";
}
else {
$industryprint="";
}
 
if (!($_REQUEST['permanent'] == "") OR !($_REQUEST['temporary'] == "")){
$permanent=$_REQUEST['permanent'];
$temporary=$_REQUEST['temporary'];
$type="$permanent $temporary";
$typeprint="Type: $type" . "\r\n";
}
else {
$typeprint="";
}
 
if (!($_REQUEST['candidate_employer'] == "")){
$candidate_employer=$_REQUEST['candidate_employer'];
$candidate_employerprint="Candidate or Employer: $candidate_employer" . "\r\n";
}
else {
$candidate_employerprint="";
}
 
if (!($_REQUEST['assist'] == "")){
$assist=$_REQUEST['assist'];
$assistprint="How can we assist you: $assist" . "\r\n";
}
else {
$assistprint="";
}
 
if (!($_REQUEST['anythingelse'] == "")){
$anythingelse=$_REQUEST['anythingelse'];
$anythingelseprint="Anything Else: $anythingelse" . "\r\n";
}
else {
$anythingelseprint="";
}
 
if (!($_REQUEST['position_title'] == "")){
$position_title=$_REQUEST['position_title'];
$position_titleprint="Position Title: $position_title" . "\r\n";
}
else {
$position_titleprint="";
}
 
if (!($_REQUEST['salary_range'] == "")){
$salary_range=$_REQUEST['salary_range'];
$salary_rangeprint="Salary Range: $salary_range" . "\r\n";
}
else {
$salary_rangeprint="";
}
 
if (!($_REQUEST['hourly_range'] == "")){
$hourly_range=$_REQUEST['hourly_range'];
$hourly_rangeprint="Hourly Range: $hourly_range" . "\r\n";
}
else {
$hourly_rangeprint="";
}
 
if (!($_REQUEST['describe_position'] == "")){
$describe_position=$_REQUEST['describe_position'];
$describe_positionprint="Describe Position: $describe_position" . "\r\n";
}
else {
$describe_positionprint="";
}
 
if (!($_REQUEST['comments'] == "")){
$comments=$_REQUEST['comments'];
$commentsprint="Comments/Messages: $comments" . "\r\n";
}
else {
$commentsprint="";
}
 
 
if (isset($_FILES["file"]["name"]) AND !($_FILES["file"]["name"] == "")){  //IF A FILES IS SUBMITTED THROUGH THE FORM THEN SEND WITH THIS
	
			if ((($_FILES["file"]["type"] == "application/msword")
			|| ($_FILES["file"]["type"] == "application/rtf")
			|| ($_FILES["file"]["type"] == "application/pdf")
			|| ($_FILES["file"]["type"] == "text/plain"))
			&& ($_FILES["file"]["size"] < 100000))
			  {
			  if ($_FILES["file"]["error"] > 0)
				{
				echo "Error: " . $_FILES["file"]["error"] . "<br />";
				}
			  else
				{
				$att_server = "attachment/".$_FILES["file"]["name"];  
				move_uploaded_file($_FILES["file"]["tmp_name"], $att_server);
					
				$from = "info@firmnyc.com";
				$to =  "$emailsend"; 
				$subject = "$subject";
				$message="$pagename$nameprint$contactnameprint$companyprint$companynameprint$phoneprint$emailprint$positionprint$industryprint$typeprint$candidate_employerprint$assistprint$anythingelseprint$position_titleprint$salary_rangeprint$hourly_rangeprint$describe_positionprint$commentsprint$positionhead$email_title$email_date$email_industry$email_term$email_salarylow$email_salaryhigh$email_bonus$email_hourlylow$email_hourlyhigh$email_city$email_state$email_group";
				$attachment = "attachment/".$_FILES["file"]["name"];
				$fileatt = $attachment; // Path to the file                  
				$fileatt_type = $_FILES["file"]["type"]; // File Type 
				$start=	0;
				$fileatt_name = substr(substr($attachment, 11), $start, strlen($attachment)); // Filename that will be used for the file as the 	attachment 
 
				$email_from = $from; // Who the email is from 
				$email_subject =  $subject; // The Subject of the email 
				 
				
				$email_to = $to; // Who the email is to
 
				$file = fopen($fileatt,'rb'); 
				$data = fread($file,filesize($fileatt)); 
				fclose($file); 
 
				$data = chunk_split(base64_encode($data));
				$mime_boundary = "Multipart_Boundary_x".md5(mt_rand())."x"; 
				
				$headers = "From: $from\r\n" .
				"MIME-Version: 1.0\r\n" .
				"Content-Type: multipart/mixed;\r\n" .
				" boundary=\"{$mime_boundary}\"" . "\r\n" ;
				
				$headers .= "This is a multi-part message in MIME format.\n\n" .
				"--{$mime_boundary}\n" .
				"Content-Type: text/plain; charset=\"iso-8859-1\"\n" .
				"Content-Transfer-Encoding: 7bit\n\n" .
				$message . "\n\n";
				
				$headers .= "--{$mime_boundary}\n" .
				"Content-Type: application/octet-stream;\n" .
				"Content-Disposition: attachment;\n" .
				" filename=\"{$fileatt_name}\"\n" .
				"Content-Transfer-Encoding: base64\n\n" .
				$data . "\n\n" .
				"--{$mime_boundary}--\n";
 
 
				$ok = @mail($email_to, $email_subject, $message, $headers); 
 
				if($ok) { 
				} 
				else { 
					die("Sorry but the email could not be sent. Please go back and try again!"); 
					} 
				
				$sentfile = "attachment/".$_FILES["file"]["name"];
				unlink($att_server);
				}
			  }
			else
			  {
			  echo "Invalid file";
			  }
} // END OF EMAIL FUNCTION IF
 
else { //IF NO ATTACHMENT FILE THEN USE THIS EMAIL SEND
			$to = "$emailsend"; 
			$subject = "$subject"; 
			$message="$pagename$nameprint$contactnameprint$companyprint$companynameprint$phoneprint$emailprint$positionprint$industryprint$typeprint$candidate_employerprint$assistprint$anythingelseprint$position_titleprint$salary_rangeprint$hourly_rangeprint$describe_positionprint$commentsprint$positionhead$email_title$email_date$email_industry$email_term$email_salarylow$email_salaryhigh$email_hourlylow$email_hourlyhigh$email_bonus$email_city$email_state$email_group"; 
			$headers = "From: info@firmnyc.com" . "\r\n" .
				"Reply-To: $email"; 
			$sent = mail($to, $subject, $message, $headers) ; 
 
}
 
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>The Abacus Group &#150; Confirmation Page</title>
<!-- <script src="rollovers.js" type="text/javascript"></script> -->
<link rel="stylesheet" href="main.css" type="text/css">
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=ABQIAAAAhqj6P2utshbr5ukWrtWfphRPlMQrS4dKyplm8TdAOpAWA7pxfBSEw78KLfAxQWS6pk7ZFSfzyL3v5Q"
      type="text/javascript"></script>
    <script type="text/javascript">
    //<![CDATA[
    function load() {
      if (GBrowserIsCompatible()) {
        var map = new GMap2(document.getElementById("map"));
        map.setCenter(new GLatLng(40.751613,-73.99204), 15);
		map.addOverlay(new GMarker(new GLatLng(40.751613,-73.99204)));
      }
    }
    //]]>
</script>
 
</head>
<body onLoad="load()" onUnload="GUnload()">
 
<!-- START of DIV wrapper to center the whole page -->
 
	<div id="wrapper">  
 
	<!-- START of MainTable, this table holds the drop shadows for the outside of the page -->
 
	<table id="maintable">
	<tr>
		<td class="top" colspan="3"><img src="images/shadow_top.jpg" width="811" height="5" alt=""></td>
	</tr>
	<tr>
		<td class="sideleft"><img src="images/spacer.gif" width="5" height="1" alt=""></td>
		<td class="content">
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
	<!-- START of HEADER TABLE -->
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
	<table id="headertable">
	<tr>
		<td class="left"><img src="images/logo.jpg" width="580" height="66" alt="Abacus Group Logo"></td>
		<td class="right"><form action="positions.php" method="POST" name="form1"><img src="images/spacer.gif" width="1" height="20" alt=""><br />SEARCH JOBS<br /><img src="images/spacer.gif" width="1" height="3" alt=""><br />
						<select name="top_position_group" class="topsearch">
						<option value="" selected>Select a position/title</option>";
					<?php
					while($row = mysql_fetch_array($resulttop))	{
						echo"<option value=\"$row[id]\">$row[groupname]</option>";
						}  ?>
						</select><input type=image align=middle SRC="images/go.gif"><br />&nbsp;<br />
						<a href="submit_position.php" class="topright">SUBMIT POSITION</a>&nbsp;&nbsp;<a href="submit_resume.php" class="topright">SUBMIT RESUME</a></form></td>
	</tr>
	</table>
	<table id="navtable">
	<tr>
		<td class="top"><img src="images/spacer.gif" width="1" height="1" alt=""></td>
	</tr>
	<tr>
		<td class="mid"><a href="index.php"><img src="images/nav/nav_01.jpg" width="93" height="33" border="0" alt="Home"></a><a href="about.php"><img src="images/nav/nav_02.jpg" width="114" height="33" border="0" alt="About Us"></a><a href="employers.php"><img src="images/nav/nav_03.jpg" width="124" height="33" border="0" alt="Employers"></a><a href="candidates.php"><img src="images/nav/nav_04.jpg" width="131" height="33" border="0" alt="candidates"></a><a href="positions.php"><img src="images/nav/nav_05.jpg" width="195" height="33" border="0" alt="Current Positions"></a><a href="contact.php"><img src="images/nav/nav_06.jpg" width="144" height="33" border="0" alt="Contact Us"></a></td>
	</tr>
	<tr>
		<td class="bottom"><img src="images/spacer.gif" width="1" height="3" alt=""></td>
	</tr>
	</table>
	<table id="bannertable">
	<?php 
	if (isset($_REQUEST['submitposition'])){
		echo "<tr><td class=\"top\"><img src=\"images/submit/submit_pic.jpg\" width=\"801\" height=\"90\" alt=\"Submit Position Pic\"></td></tr><tr><td class=\"mid\"><img src=\"images/submit/submit_title.jpg\" width=\"801\" height=\"35\" alt=\"Submit Position Title\"></td></tr>";
		$background = "images/submit/submit_desc_bg.jpg";
	}
	elseif (isset($_REQUEST['submitresume'])){
		echo "<tr><td class=\"top\"><img src=\"images/resume/submit_pic.jpg\" width=\"801\" height=\"90\" alt=\"Submit Resume Pic\"></td></tr><tr><td class=\"mid\"><img src=\"images/resume/submit_title.jpg\" width=\"801\" height=\"35\" alt=\"Submit Resume\"></td></tr>";
		$background = "images/resume/submit_desc_bg.jpg";
	}
	elseif (isset($_REQUEST['submitapply'])){
		echo "<tr><td class=\"top\"><img src=\"images/apply/submit_pic.jpg\" width=\"801\" height=\"90\" alt=\"Apply Pic\"></td></tr><tr><td class=\"mid\"><img src=\"images/apply/apply_title.jpg\" width=\"801\" height=\"35\" alt=\"Apply Title\"></td></tr>";
		$background = "images/resume/submit_desc_bg.jpg";
	}
	else {
		echo "<tr><td class=\"top\"><img src=\"images/contact/contact_pic.jpg\" width=\"801\" height=\"90\" alt=\"Contact Pic\"></td></tr><tr><td class=\"mid\"><img src=\"images/contact/contact_title.jpg\" width=\"801\" height=\"35\" alt=\"Contact Title\"></td></tr>";
		$background = "images/contact/contact_desc_bg.jpg";
	}
	?>
	
	<tr>	
		<td class="bottom" height="107" style="background: url(<?php echo "$background"; ?>);"><p>Please feel free to contact one of our consultants about your career search or staffing needs. </p></td>
	</tr>
	</table>
	<!-- START of the main CONTENT TABLE, this table holds the smaller tables that make up the main content window -->
	<table id="contenttable">
	<tr>
		<!-- START the LEFT content the td holds all the stuff in the left column -->
		<td class="left">
			<div> <!--  DIV tag For IE to center the TD Cell --->
			<!-- This table is a smaller table used to hold the boxed info for this column in here are the drop shaddows for this box -->
			<p class="contact">
             <span class="abacus">THE ABACUS GROUP</span><br />
			 14 Penn Plaza, Suite 1600<br />
			 New York, NY 10122<br />
			 &nbsp;<br />
			 <b>phone </b>212.812.8444<br />
			 <b>fax </b>212.812.8448<br />
			 <b>e-mail </b><a href="mailto:info@firmnyc.com" class="contact">info@firmnyc.com</a></p>
			 <div id="map" style="width: 211px; height: 145px; margin: 0 38px 0 38px;"></div>
			 <p class="map"><a href="http://maps.google.com/maps?q=14+Penn+Plaza,+New+York,+NY+10001,+USA&sa=X&oi=map&ct=title" target="_blank" class="map">Map & Driving Directions</a></p>
			
			<!-- End of this smallbox -->
			</div>
		</td>
		<!-- START of the content that goes on the LEFT side of the main content window -->
		<td class="right">
		<h1>THANK YOU</h1>
		<p class="text">
		<?php 
		if($sent OR $ok) 
			{print "Your email was sent successfully"; }
		else 
			{print "We encountered an error sending your mail"; }
		?>
		<?php if($search_flag == 1){ 
		echo "<br />&nbsp;<br />";
		echo "<a href=\"$search_url\" class=\"positionheader\">back to search results &#62;&#62;</a>";
		}?>
		</p>
		</td>
		<!-- End of the LEFT side content -->
	</tr>	
	</table>
	<!-- End of the CONTENT TABLE -->
	<br />
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
	<!-- START of FOOTER TABLE -->
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
	<table id="footertable">
	<tr>
		<td class="top" colspan="2"><img src="images/count_on_us.jpg" width="79" height="13" alt="count on us"></td>
	</tr>
	<tr>
		<td class="mid" colspan="2"><hr></td>
	</tr>
	<tr>	
		<td class="bottomleft"><img src="images/spacer.gif" width="1" height="1" alt=""><br /><a href="privacy.html" class="footer">privacy policy</a><img src="images/dots.gif" width="23" height="18" alt="dots" align="middle"><a href="sitemap.html" class="footer">site map</a></td>
		<td class="bottomright"><p>14 penn plaza, suite 1600, new york, new york 10122<br />
		<b><i>telephone</i></b> 212.812.8444 &#149; <b><i>fax</i></b> 212.812.8448 &#149; <a href="mailto:info@firmnyc.com" class="email">info@firmnyc.com</a></p></td>
	</tr>
	</table>
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
	<!-- END of CONTENT TABLE -->
	<!-- \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ -->
 
	<br />
	</td>
	<td class="sideright"></td>
	</tr>
	<tr>
		<td class="top" colspan="3"><img src="images/shadow_bottom.jpg" width="811" height="5" alt=""></td>
	</tr>
	</table>
	<!-- END of MAIN TABLE -->
	</div>
	<!-- END of DIV for wrapper -->	
 
 
</BODY>
</HTML>
<?php

Open in new window

Email ServersPHP

Avatar of undefined
Last Comment
Marcus Bointon

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
eft0

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
jsuissa

ASKER
So we should just substitue this code to fix the issue or are you just asking for verification to help you diagnose the problem better.

Thanks.
Marcus Bointon

This kind of problem is pretty much what you expect when not using a tried and tested class - it's extremely easy to get RFC822 formatting wrong. There is no good reason not to use such a class - there are plenty of freely (non-GPL) licensed ones that will work very nicely such as PHPMailer and SwiftMailer. In your example message, one glaring error is that there is a blank line between the subject and content-type headers - just that will probably cause the content to appear inline as it totally screws the whole message structure. The return path is also split off, and the address in it should be surrounded by <>.

There is no way that messages will be going to the wrong address if they are addressed correctly, so I suggest that you review your address selection code, and do a dump to a log file of the exact final messages and headers as submitted to sendmail. Your problems are pretty much guaranteed to be on the sending side.
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy