Security News
GitHub Removes Malicious Pull Requests Targeting Open Source Repositories
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
The sendmail npm package is a simple way to send emails from your Node.js application without needing a dedicated SMTP server. It uses the sendmail command available on Unix-like systems to send emails.
Send a basic email
This feature allows you to send a basic email with a subject and HTML content. The sendmail function is called with an options object containing the email details.
const sendmail = require('sendmail')();
sendmail({
from: 'no-reply@yourdomain.com',
to: 'user@example.com',
subject: 'Test Email',
html: 'This is a test email',
}, function(err, reply) {
console.log(err && err.stack);
console.dir(reply);
});
Send an email with attachments
This feature allows you to send an email with attachments. The attachments property is an array of objects, each representing a file to be attached to the email.
const sendmail = require('sendmail')();
sendmail({
from: 'no-reply@yourdomain.com',
to: 'user@example.com',
subject: 'Test Email with Attachment',
html: 'This is a test email with an attachment',
attachments: [
{ // file on disk as an attachment
filename: 'text1.txt',
path: '/path/to/file.txt' // stream this file
}
]
}, function(err, reply) {
console.log(err && err.stack);
console.dir(reply);
});
Nodemailer is a module for Node.js applications to allow easy email sending. It supports various transport methods, including SMTP, and offers more features and flexibility compared to sendmail. It is widely used and has extensive documentation.
EmailJS is a library for sending emails from JavaScript applications. It supports SMTP and offers features like email templating and attachments. It is more feature-rich and flexible compared to sendmail.
SMTP Server is a simple and configurable SMTP server for Node.js. It allows you to create your own SMTP server for sending and receiving emails. It provides more control and customization options compared to sendmail.
Send mail without SMTP server
If you're interested in helping out this repo, please check out the roadmap below to see if anything interests you
npm install sendmail --save
# or
yarn add sendmail
const sendmail = require('sendmail')({
logger: {
debug: console.log,
info: console.info,
warn: console.warn,
error: console.error
},
silent: false,
dkim: { // Default: False
privateKey: fs.readFileSync('./dkim-private.pem', 'utf8'),
keySelector: 'mydomainkey'
},
devPort: 1025, // Default: False
devHost: 'localhost', // Default: localhost
smtpPort: 2525, // Default: 25
smtpHost: 'localhost' // Default: -1 - extra smtp host after resolveMX
})
const sendmail = require('sendmail')();
sendmail({
from: 'no-reply@yourdomain.com',
to: 'test@qq.com, test@sohu.com, test@163.com ',
subject: 'test sendmail',
html: 'Mail of test sendmail ',
}, function(err, reply) {
console.log(err && err.stack);
console.dir(reply);
});
Please checkout our great examples
Note if you were on any previous version before <1.0.0
You will need to start using html
instead of content
. Instead of creating emails ourselves anymore we have decided to use mailcomposer
to compose our emails. Which means we can give you the same great package with the best mail composer package out there.
In 1.2.0 "Converted to ES2015" which will break node 4.x
Note we use mailcomposer
to compose our mail before we send it out so all mail options will be well documented Here. But for those who want something particular go ahead and search down below.
Below are a list of the most used options for email fields. Please read the entire list of options here Here:
You are also able to send attachents. Please review the list of properties here Here
In addition to text and HTML, any kind of data can be inserted as an alternative content of the main body. Please check that out Here
All e-mail addresses can be formatted. Please check that out Here
SMTP envelope is usually auto generated from from
, to
, cc
and bcc
fields but you can change them Here
Attachments can be used as embedded images in the HTML body. To use this feature, you need to set additional properties Here
dkim
object to options that can have two properties: privateKey
and keySelector
. These options correspond to the options for dkim-signer
. Added an example for these options. Special thanks goes out to download13 for PR 23Please reach out to Green Pioneer. If I dont respond the first time please feel free to reach out again to get help( Also try using @greenpioneer in issues or prs). Guileen is the original creator.
FAQs
Sendmail without setting up SMTP server
We found that sendmail demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.