Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add email download #23

Merged
merged 1 commit into from
Apr 9, 2024
Merged

Add email download #23

merged 1 commit into from
Apr 9, 2024

Conversation

domdomegg
Copy link
Owner

Via email:

Dear Mr. Jones,

I hope this email finds you well. My name is [redacted], and I wanted to reach out to you regarding your excellent project, "aws-ses-v2-local." I have implemented a new feature that allows for the download of emails in the eml format.

If you have a moment, I would greatly appreciate it if you could review the forked repository (https://github.com/Ymmy833y/aws-ses-v2-local) and consider merging the changes into the next release.

Should you have any questions, concerns, or feedback regarding the implementation, please feel free to contact me. I understand that you are incredibly busy, but I would be honored to receive your insights.

Thank you for your time and consideration. I look forward to hearing from you.

Copy link
Owner Author

@domdomegg domdomegg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Ymmy833y for this great patch!

Happy to accept it after reviewing one thing: the downloaded .eml file uses CRLF, rather than just LF. On MacOS and Linux systems this seems to confuse some programs that process emails, e.g. MacOS preview doesn't display the emails correctly.

Can we either:

  • Confirm CRLF is the correct format for the standard, and we should raise bugs against programs that don't process this properly (like MacOS preview); or
  • Adjust the download to use the right line endings for the system downloading the file

@Ymmy833y
Copy link
Contributor

Ymmy833y commented Apr 7, 2024

@domdomegg sorry for the late reply. Thank you for checking this new feature.

Regarding the line endings issue, it appears that the root cause lies within Nodemailer (issue 1639).

As a workaround for this issue, I could propose reformatting the return value of transporter.sendMail to use the appropriate line endings for the platform.

For example:

transporter.sendMail(convertToMailOptions(email), (error, info) => {
  if (!error) {
    resolve({
      messageId: email.messageId,
      fileName: email.subject,
      body: (process.platform === 'win32') ? info.message : convertCRLFtoLF(info.message)
    });
    ...

  }
});

const convertCRLFtoLF = (buffer: Buffer): Buffer => {
  return Buffer.from(buffer.toString().replace(new RegExp('\r\n', 'g'), '\n'));
}

However, since there is a possibility that this issue may not be resolved in the future and the functionality may be removed, merging a pull request may not be the best solution at this time.

I will keep you updated if I receive any further information regarding this issue.

@domdomegg
Copy link
Owner Author

On further review, I think that other programs should handle CRLF line feeds better because this is the standard. I've raised a bug report against Apple Preview and will be merging this PR. Thanks for the great contribution @Ymmy833y! 🙌

@domdomegg domdomegg merged commit 6c318e2 into domdomegg:master Apr 9, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants