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)
- Not Sending Email (Error: Missing credentials for "PLAIN") HOT 6
- What would be the recipe to encrypt the email with sender's certificate HOT 2
- Too long URLs in the List-Unsubscribe header causes the DKIM signature verification to fail HOT 4
- Invalid login: 535-5.7.8 Username and Password not accepted HOT 5
- Nodemailer not working in my ubuntu vps server, but works on localhost (windows) both development and production HOT 1
- Nodemailer is not working in production HOT 2
- Github-Actions closing valid issues HOT 4
- SES Email transport throttling callback HOT 2
- Azure Functions v4 - Authentication Unsuccessful HOT 2
- nodemailer authorisation error due to MFA HOT 3
- UNHANDLED PROMISE REJECTION node js HOT 3
- help UNHANDLED PROMISE REJECTION The promise rejected with the reason "SMTP ERROR => connect ETIMEDOUT 52.101.151.0.25".] { HOT 2
- Allow usage of `https://www.googleapis.com/auth/gmail.modify` Gmail OAuth scope HOT 1
- DKIM configuration for Zoho HOT 1
- Some BCC email ID not Getting mail
- Problem sending emails to gmail
- List-Unsubscribe header is not compliant when multiple values are specified HOT 1
- Not able to receive .eml files from nodemailer in outlook. Working fine in gmail
- DKIM signature failure HOT 2
- Whitespace on attachment's filename is being url encoded
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.