Newbie: Apache/1.3.19 (Unix) PC: MS-Outlook
Corrupted \n\r in phpmailer attachments.
Three attachments: NP.txt from Notepad, W.doc from MS-Word, PDF.pdf from AdobePDF, all generated from NP.txt. When mailed to me or to someone else NP.txt can be opened but has corrupted \n\r characters. Word can't open W.doc and Adobe Reader can't open PDF.pdf. Both mail() and smtp transfers fail. No errors are flagged (that I've found). I assume that when \n\r corruption is resolved the other files will transfer, so I only test NP.txt transfer now.
Permissions set to 777 doesn't help.
Stripping or adding slashes before mailing doesn't help.
Encoding in base64 doesn't help (other files not tried).
Appended here:
1) The script, P2HPmailer.php
2) Mail with NP.txt attached as received in my unix mail box.
3) The original NP.txt file
In the Body of the script are listed various tests run (seemed logical to a beginner).
I've been on this a long time w/o cracking it. Any suggestions appreciated, Ed
=========================== P2HPmailer.php ===============================
/* P2HPmailer.php v. 2June03 7:15 pm */
<?
/* This version delivers the 4 files but
the two *.txt have corrupted \n\r characters and the other two, .doc and .pdf., can't be opened. */
$when = date ("1 F d Y h:i:s A");
require("class.phpmailer.php");
$mail->$UseMSMailHeaders = true;
$mail = new PHPMailer();
//$mail->IsMail();
$mail->IsSMTP();
$mail->Mailer = "smtp";
$mail->Host = "mail.u-sit.net"; // Use SMTP
$mail->Hostname = "u-sit";
$mail->SMTPAuth = false; // Default is false.
$mail->SMTPDebug = true;
$mail->From = "ntelleck@u-sit.net";
$mail->FromName = "P2HPmailer.php -- Ed";
$mail->AddAddress ("Ntelleck@u-sit.net");
$mail->AddReplyTo ("ntelleck@u-sit.net");
$mail->WordWrap = 60;
$atch1 = "/home/www/u-sit/PHPfiles/DearTstrs.txt";
$atch2 = "/home/www/u-sit/PHPfiles/DearTstrs.doc";
$atch3 = "/home/www/u-sit/PHPfiles/DearTstrs.pdf";
$atch4 = "P2HPmailer.php"; // this script
$mail->AddAttachment($atch1);
//$mail->AddAttachment($atch2);
//$mail->AddAttachment($atch3);
//$mail->AddAttachment($atch4);
$mail->IsHTML(true); // send as HTML
$mail->Subject = "Test of PHPmailer.php from Ed";
$mail->Body = "<b>Testing strategy:</b>
<BR>1. Change script name from PHPmailer.php to PHP2mailer.php: -- NO effect = file delivered /w corrupted \n\r
<BR> Permissions on the 4 files: rwxr-xr-x
<BR>2. Use full addresses to attached files: -- NO effect.
<BR>3. Work on just the Notepad generated file, DearTstrs.txt, since it has corrupted \n\r ascii characters.
<BR> Once corrupted \n\r are resolved, try .doc, .pdf, and .jpg files.
<BR>4. In MS-Outlook: Allow 8-bit characters in headers. -- NO effect
<BR>5. Encoding = base64 -- NO effect
<BR>6. Changed from IsMail() to Mailer=sendmail -- NO effect
<BR>7. Stripped slashes: AddAttachment(stripcslashes($atch1)) -- NO effect
<BR>8. Change FromAddress to From -- NO effect
<BR>9. Added slashes: $mail->AddAttachment(addslashes($atch1)) -- NO effect
<BR>10. Removed $mail->Host = 'mail.u-sit.net'; -- NO effect
<BR>11. Removed $mail->AltBody = 'This is the text-only body' -- NO effect
<BR> SMTP tests:
<BR>12. Uncommented $mail->Host = 'mail.u-sit.net' -- NO effect
<BR>13. Added Hostname = 'u-sit' -- NO effect
<BR>14. Set, $mail->Mailer = 'smtp' -- No effect
<BR>15. Set, SMTPDebug = true, Cut/Paste output to Notepad and format (\n\r) for readability
<BR>16. Set permissions to 777 for attached files. -- No effect
<BR>17. Set, $mail->IsSMTP(); -- No effect
<BR>18. u-sit@u-sit.net mail goes to web-site mail box
<BR>19. $mail->$UseMSMailHeaders = true; -- No effect
<BR>
<BR>Attached are 1 files *.txt files.
<BR>Please REPLY to let me know their arrival/condition.
<BR>Files were sent $when Do *.txt and *.php have non ascii characters? ";
//$mail->AltBody = "This is the text-only body"; // Sets email to multipart/alternative.
//$mail->Encoding = "base64";
if(!$mail->Send())
{
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
echo "Message has been sent";
echo "<BR>";
echo date ("l dS of F Y h:i:s A");
echo "<BR>Last mail error: $ErrorInfo";
?>
================================ As-delivered to unix mail box with NP.txt attached ==================
Message 8:
From ntelleck@u-sit.net Mon Jun 2 20:08:23 2003
Date: Mon, 2 Jun 2003 20:08:23 -0500
To: u-sit@u-sit.net
From: "P2HPmailer.php \-\- Ed" <ntelleck@u-sit.net>
Reply-to: ntelleck@u-sit.net
Subject: Test of PHPmailer.php from Ed
X-Priority: 3
X-Mailer: phpmailer [version 1.65]
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="b1_e6355795c1abb4a19d4ca9a9dd1a5097"
X-Status:
X-Keywords:
X-UID: 8
--b1_e6355795c1abb4a19d4ca9a9dd1a5097
Content-Type: text/html; charset = "iso-8859-1"
Content-Transfer-Encoding: 8bit
<b>Testing strategy:</b>
<BR>1. Change script name from PHPmailer.php to
PHP2mailer.php: -- NO effect = file delivered /w corrupted
<BR> Permissions on the 4 files: rwxr-xr-x
<BR>2. Use full addresses to attached files: -- NO
effect.
<BR>3. Work on just the Notepad generated file,
DearTstrs.txt, since it has corrupted
ascii characters.
<BR> Once corrupted
are resolved, try .doc, .pdf, and .jpg files.
<BR>4. In MS-Outlook: Allow 8-bit characters in headers.
-- NO effect
<BR>5. Encoding = base64 -- NO effect
<BR>6. Changed from IsMail() to Mailer=sendmail -- NO
effect
<BR>7. Stripped slashes:
AddAttachment(stripcslashes(/home/www/u-sit/PHPfiles/DearTstrs.txt)) --
NO effect
<BR>8. Change FromAddress to From -- NO effect
<BR>9. Added slashes:
(addslashes(/home/www/u-sit/PHPfiles/DearTstrs.txt)) -- NO
effect
<BR>10. Removed mail.u-sit.net = 'mail.u-sit.net'; -- NO
effect
<BR>11. Removed = 'This is the text-only body' -- NO
effect
<BR> SMTP tests:
<BR>12. Uncommented mail.u-sit.net = 'mail.u-sit.net' --
NO effect
<BR>13. Added Hostname = 'u-sit' -- NO effect
<BR>14. Set, smtp = 'smtp' -- No effect
<BR>15. Set, SMTPDebug = true, Cut/Paste output to Notepad
and format (
) for readability
<BR>16. Set permissions to 777 for attached files. -- No
effect
<BR>
<BR>Attached are 1 files *.txt files.
<BR>Please REPLY to let me know their arrival/condition.
<BR>Files were sent 1 June 02 2003 08:08:23 PM Do *.txt
and *.php have non ascii characters?
--b1_e6355795c1abb4a19d4ca9a9dd1a5097
Content-Type: application/octet-stream; name="DearTstrs.txt"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="DearTstrs.txt"
RGVhciB0ZXN0ZXJzOgoKVGhpcyBpcyBhIHNpbXBsZSB0ZXh0IGZpbGUKdG8gc2VlIGhvdyB3ZWxs
IGF0dGFjaG1lbnRzIHRvIGEgbWFpbCBzY3JpcHQKd29yayBvbiB5b3VyIHN5c3RlbS4KCkl0J3Mg
YmVpbmcgc2VudCB0aHJlZSBmb3JtYXRzOiAgCglOb3RlUGFkJ3MgKi50eHQgZm9ybWF0LCAKCVdv
cmQncyAgICAqLmRvYyBmb3JtYXQsIGFuZCAKCUFkb2JlJ3MgICAqLnBkZiBmb3JtYXQuCgpQbGVh
c2UgbGV0IG1lIGtub3cgdGhhdCB5b3UgZ2V0IHRoZSBlbWFpbCBhbmQgd2hpY2ggYXR0YWNobWVu
dHMgeW91IGFyZSBhYmxlIHRvIG9wZW4uIApBbHNvIGluZGljYXRlIHdoZXRoZXIgYW55IG9mIHRo
ZSB0ZXh0IGluIHRoZSBvcGVuZWQgYXR0YWNobWVudHMgaXMgZ2FyYmxlZC4KClRoYW5rcyBmb3Ig
dGhlIGhlbHAuCgpFZCBTaWNrYWZ1cyAoZXNpY2thZnVzQHUtc2l0Lm5ldCk=
--b1_e6355795c1abb4a19d4ca9a9dd1a5097--
=================== Original NP.txt file =====================================
Dear testers:
This is a simple text file
to see how well attachments to a mail script
work on your system.
It's being sent three formats:
NotePad's *.txt format,
Word's *.doc format, and
Adobe's *.pdf format.
Please let me know that you get the email and which attachments you are able to open.
Also indicate whether any of the text in the opened attachments is garbled.
Thanks for the help.
Ed Sickafus (esickafus@u-sit.net)
===============================================================================
Corrupted \n\r in phpmailer attachments.
Moderator: General Moderators
-
Ed Sickafus
- Forum Newbie
- Posts: 2
- Joined: Thu May 22, 2003 9:21 am
- Location: Grosse Ile, MI