Last active
January 28, 2021 15:10
-
-
Save gr2m/5463552 to your computer and use it in GitHub Desktop.
Imagine you could send emails with JavaScript, multipart, and with attachments?! How would the code look like? This is what I came up with. Forks & comments much appreciated! #nobackend #dreamcode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// send text email | |
sendEmail({ | |
subject: "Hello, World!", | |
text: "This mail has been sent from the frontend", | |
to: "[email protected]" | |
}) | |
// send multipart text / html email | |
sendEmail({ | |
subject: "Hello, World!", | |
text: "This mail has been sent from the frontend", | |
html: "<p>This mail has been sent from the frontend</p>", | |
to: "[email protected]" | |
}) | |
// send multipart with attachment | |
sendEmail({ | |
subject: "Hello, World!", | |
text: "This mail has been sent from the frontend", | |
html: "<p>This mail has been sent from the frontend</p>", | |
to: "[email protected]", | |
attachments: [ | |
convert( document.body ).to("screenshot.png"), | |
{ filename: "info.text", data: "Some info about the page"} | |
] | |
}) |
Using CORS it will prevent sending emails from not allowed pages. But it's difficult to find a way that solves everything. 😢
Can I deliver OBIEE report as Email attachment to all Users belong to particular Role instead of individual User ? using OBIEE 11.1.7.x. Any help appreciated.
How can i use this,Will u please help me out here
@sudharsan203, It says #dreamcode at the top. Based upon this and other research I've completed, I don't believe this is possible.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I understand the security concerns, but please understand that this is out of scope here. Think of it as a wrapper to what ever is used behind the curtain to securely send multipart emails. If http requests to a backend are used, then it's the back-end's job to make this secure. The front-end just expresses the intent to do so, and if the server denies is, the error will be transparently passed to the returned promise.