Comments (6)
Streamed attachments are possible in theory but not something trivial. It is possible to use streams because attachments don't need any size or length headers in the mime body - you can add anything you want and close the attachment with the predefined boundary when the file is finished streaming.
Firstly a base64 encoder for streams is required. This is not very difficult, I have created base64 decoder which needs be reversed (encoding instead of decoding). https://gist.github.com/576480
Secondly, message body generation needs to be reimplemented, since currently it builds the whole message body as one large string but this needs to be done on the SMTP side instead. After emitting DATA command and sending the headers, mail body needs to be streamed, first text parts and then the streamed attachments.
DATA\r\n
Headers....\r\n
\r\n
----boundary-----\r\n
text
----boundary-----\r\n
html
----boundary-----\r\n
stream base64(attachment1)
----boundary-----\r\n
stream base64(attachment2)
....
----boundary-----\r\n
.
Doable but not trivial.
from nodemailer.
I'm actually trying to get nodemailer working with large attachments.
With sending to a SMTP, the bottleneck is when sending the data to the SMTP and it's getting very slow.
When using sendmail, there was an issue because the command line was too long. I tried to switch to streams and to pipe the mail into sendmail, which was also very slow. I finally decided to write the email in a file, and then I spawn "sendmail < file". This seems to be much faster. Any idea why?
from nodemailer.
Hi, is the SMTP server a local one or remote (gmail etc.)? I think that sendmail caches the mail file instead of sending it immediatelly and thus when the program returns then the mail is not yet sent but queued to be sent on first opportunity. But I might be wrong about it, I'm not so familiar with sendmail.
from nodemailer.
Yes you are correct regarding the queuing but actually it was putting the message in the queue which was very slow.
To summarize I had the slowness issue in the following cases:
- Connecting to a local SMTP server (on localhost).
- Piping into the Sendmail process (using the node.js pipe API)
It was fast when doing:
- Writing a file to disk, then spawning Sendmail and read from that file.
from nodemailer.
Actually I implemented the faster solution here: https://github.com/bvirlet/Nodemailer/tree/large-attachments
But it's not 100% satisfying since I don't understand why it is slow in the other cases.
from nodemailer.
New v0.3 branch includes file streaming.
from nodemailer.
Related Issues (20)
- Unable to Receive signup emails for my application for other domains other than Microsoft HOT 4
- Close previous connections HOT 1
- Fails to resolve dependencies: webpack < 5 used to include polyfills for node.js core modules by default. HOT 2
- icalEvent option producing incorrect attachment headers HOT 2
- Empty email body in Apple/iOS Mail with ical and attachments HOT 4
- Authentication unsuccessful, the request did not meet the criteria to be authenticated successfully. Contact your administrator HOT 2
- email added to my imap sent folder displays symbols instead of Arabic characters HOT 1
- No Newline Processing with Raw Attachment HOT 2
- Unhandled errors in attachements HOT 4
- Nodemailer doesn't work on Cloudflare Workers because it uses Built-in node modules without `node:` prefix HOT 5
- Node-mailer: Problem with rendering node mail images in the body. HOT 1
- Not working on serverless edge functions HOT 7
- Unable to use with Brevo(aka send in blue) | Nextjs 14 HOT 1
- Sonatype reports 6.9.9 as vulnerable due to resolveContent() function of the lib/shared/index.js file HOT 1
- Sending mail using nodemailer is slower HOT 3
- ReDoS when try to send a specially crafted email HOT 2
- Connection Refused on CPanel HOT 2
- Can't handle ReadableStream from fetch as attachment HOT 1
- Double quotes being removed from headers with single quotes, leading to rejections HOT 3
- npm attestation broken as of 6.9.11 HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodemailer.