Connecting Tech Pros Worldwide Help | Site Map

Apple Mail sees attachment in generated email but cannot open

  #1  
Old March 24th, 2008, 07:45 PM
jerrygarciuh
Guest
 
Posts: n/a
Hi folks,

I have a PHP cron job that compiles a CSV from queries and emails it
to some clients. I have a complaint that one client can see the
indicating icon to say there is an attachment in his Apple Mail but
attempts to open it fail. If he forwards the email to Gmail he can
open the attachment from there so it is a mail client issue, not a
file issue.

This sounds to me like maybe the boundaries I am setting have issues?
Anyone have experience or ideas about a fix? Here is the offending
function.

TIA!

JG


function sendAttachment($csvName, $message, $emails) {
$csv = implode('', file("reports/$csvName.csv"));
$date = date( 'r' );
$phpversion = phpversion();
$boundary = md5( time() );
$filename = "$csvName.csv";
$headers = <<<END
From: myaddress@cox.net
Reply-To: myaddress@cox.net
Return=Path: myaddress@cox.net
Date: $date
X-Mailer: PHP v$phpversion
MIME-Version: 1.0
Content-Type: multipart/related; boundary="$boundary"
END;

$message = <<<END
--$boundary
Content-Type: text/plain; charset="iso-9959-1"
Content-Transfer-Encoding: 7bit

$message

--$boundary
Content-Type: octet-stream; name="$filename"
Content-Disposition: attachment; filename="$filename"
Content-Transfer-Encoding: 7bit

$csv

--$boundary--

END;

return mail( join($emails, ','), $csvName, $message, $headers );
} // func
  #2  
Old March 24th, 2008, 08:05 PM
jerrygarciuh
Guest
 
Posts: n/a

re: Apple Mail sees attachment in generated email but cannot open


On Mar 24, 1:42 pm, jerrygarciuh <jerrygarc...@gmail.comwrote:
Quote:
Hi folks,
>
I have a PHP cron job that compiles a CSV from queries and emails it
to some clients. I have a complaint that one client can see the
indicating icon to say there is an attachment in his Apple Mail but
attempts to open it fail. If he forwards the email to Gmail he can
open the attachment from there so it is a mail client issue, not a
file issue.
>
This sounds to me like maybe the boundaries I am setting have issues?
Anyone have experience or ideas about a fix? Here is the offending
function.
>
TIA!
>
JG
>
function sendAttachment($csvName, $message, $emails) {
$csv = implode('', file("reports/$csvName.csv"));
$date = date( 'r' );
$phpversion = phpversion();
$boundary = md5( time() );
$filename = "$csvName.csv";
$headers = <<<END
From: myaddr...@cox.net
Reply-To: myaddr...@cox.net
Return=Path: myaddr...@cox.net
Date: $date
X-Mailer: PHP v$phpversion
MIME-Version: 1.0
Content-Type: multipart/related; boundary="$boundary"
END;
>
$message = <<<END
--$boundary
Content-Type: text/plain; charset="iso-9959-1"
Content-Transfer-Encoding: 7bit
>
$message
>
--$boundary
Content-Type: octet-stream; name="$filename"
Content-Disposition: attachment; filename="$filename"
Content-Transfer-Encoding: 7bit
>
$csv
>
--$boundary--
>
END;
>
return mail( join($emails, ','), $csvName, $message, $headers );
>
} // func

Solved! Replaced:

Content-Type: multipart/related; boundary="$boundary"

With:

Content-Type: multipart/mixed; boundary="$boundary"

Peace,

JG
Closed Thread