arithmetric / aws-lambda-ses-forwarder

Serverless email forwarding using AWS Lambda and SES
MIT License
1.7k stars 450 forks source link

Fix expected field headers format #101

Closed ccjmne closed 4 years ago

ccjmne commented 5 years ago

Fixes #86.

As described in the RFC 5322 – Internet Message Format, from:Betsy <betsy@example.com> should be accepted and understood.

Basically, fields don't have to look like From: ccjmne@gmail.com, they could very well be: from:ccjmne@gmail.com (note the non-capitalized field header and the absence of a whitespace immediately following the colon :).

I ensured this would work for the relevant fields, and slightly modified the test/assets/message.txt file to reproduce the uncommon "lowercase header, colon, no-space, body" field pattern.


Also, according to that same RFC, the "carriage return/line feed" pair should always appear together. In other words, \r?\n should really be: \r\n ; but I figure it's safe being too lenient there so I'll leave these unchanged.

alejandroclose commented 4 years ago

Great fix @ccjmne! @arithmetric Thank you for the original code! The forwarder kept giving me the error: 'sendRawEmail() returned error.', InvalidParameterValue: Empty header names are illegal. until I applied these changes.

KeepRowing

ccjmne commented 4 years ago

Awesome! I'm glad it worked for you 😄

arithmetric commented 4 years ago

Thanks for this contribution @ccjmne!