DZone
Web Dev Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Web Dev Zone > Generating Emails Using Node.js

Generating Emails Using Node.js

Axel Rauschmayer user avatar by
Axel Rauschmayer
·
Feb. 29, 12 · Web Dev Zone · Interview
Like (0)
Save
Tweet
5.24K Views

Join the DZone community and get the full member experience.

Join For Free
This post tells you how to generate emails on Node.js and open them in an email program. It uses mailto URLs to do so. The advantage of this approach is that you can manually check and edit such emails before sending them.

mailto URL syntax

"mailto:" recipients ( "?" key "=" value ("&" key "=" value)* )?

  • recipients: comma-separated email addresses (no spaces; Outlook needs semicolons instead of commas)
  • value: should be URL-encoded (e.g. space becomes %20)
  • key: subject, cc, bcc, body

Example: mailto:joe@example.com,jane@example.com?subject=hello&body=How%20are%20you%3F

Using mailto URLs on Node.js

The npm module openurl allows you to tell the operating system to open a URL. It also comes with a mailto() function that constructs well-formed mailto URLs. Example:
    require("openurl").mailto(["john@example.com", "jane@example.com"],
        { subject: "Hello!", body: "This is\na generated email!\n" });

Naturally, the same technique also works with other programming languages:

  • A simple way of sending emails in Java: mailto links
  • Generate emails with mailto URLs and Python



Node.js

Published at DZone with permission of Axel Rauschmayer, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • The Importance of Semantics for Data Lakehouses
  • Purpose-Driven Microservice Design
  • Troubleshooting HTTP 502 Bad Gateway in AWS EBS
  • Understanding Kubernetes Resource Types

Comments

Web Dev Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo