Invalid content on base64 encoded emails after server update

Linux OS Topics
Post Reply
User avatar
Saman
Lieutenant Colonel
Lieutenant Colonel
Posts: 828
Joined: Fri Jul 31, 2009 10:32 pm
Location: Mount Lavinia

Invalid content on base64 encoded emails after server update

Post by Saman » Thu Mar 22, 2012 1:21 am

I recently found that all my base64 encoded emails are not incorrectly encoded. The reason is I updated the server.

The email came as below.

Code: Select all

Content-Transfer-Encoding: base64
Message-Id: <[email protected]>
Date: Wed, 20 Mar 2012 20:05:14 +0530 (GMT)

LS0tLS1CRUdJTiBQR1AgTUVTU0FHRS0tLS0tClZlcnNpb246IEdudVBHIHYxLjQuNSAoR05VL0xp
bnV4KQoKaFFJT0F6SzVKcHZnNWJLR0VBZi9RaUkza3llcW9KL0NCU3l3SjVCZ0Z6UzJZOHByUGxD
WlFpTis0eHN2VVM2MwpXbTVjQzM2MUNCamFXMWIxc2kvR1NYMTlCTSsxdHNqenZVcGxaNXlDNFdM
....
....
This is not the message I expected.

After several attempts, I found the reason for this.

On the php code, I was having,

Code: Select all

$headers = 'From: [email protected]' . "\r\n";
$headers .= 'Content-Transfer-Encoding: base64' . "\r\n"; 
I found out, these needs to be changed as below (removing \r),

Code: Select all

$headers = "From: [email protected]\n";
$headers .= "Content-Transfer-Encoding: base64\n"; 
All worked as expected. Hope this will help!
Post Reply

Return to “Linux”