Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up

📫 SMTP Server + Web Interface for viewing and testing emails during development.

License

NotificationsYou must be signed in to change notification settings

maildev/maildev

Repository files navigation

npmnpm downloadsDocker PullsLicenseJavaScript Style Guide

MailDev is sponsored by ⭐️inngest/inngest.

Inngest is the developer platform for easily building reliable workflows with zero infrastructure. Check it out and give it a star! ⭐️

MailDev is a simple way to test your project's generated email during development, with an easy to use web interface that runs on your machine built on top ofNode.js.

MailDev Screenshot

Docker Run

If you want to use MailDev withDocker, you can use themaildev/maildev image on Docker Hub.For a guide for usage with Docker,checkout the docs.

$ docker run -p 1080:1080 -p 1025:1025 maildev/maildev

Usage

Usage: maildev [options]
OptionsEnvironment variableDescription
-s, --smtp <port>MAILDEV_SMTP_PORTSMTP port to catch mail
-w, --web <port>MAILDEV_WEB_PORTPort to run the Web GUI
--mail-directory <path>MAILDEV_MAIL_DIRECTORYDirectory for persisting mail
--httpsMAILDEV_HTTPSSwitch from http to https protocol
--https-key <file>MAILDEV_HTTPS_KEYThe file path to the ssl private key
--https-cert <file>MAILDEV_HTTPS_CERTThe file path to the ssl cert file
--ip <ip address>MAILDEV_IPIP Address to bind SMTP service to, defaults to:: (any IPv4/v6)
--outgoing-host <host>MAILDEV_OUTGOING_HOSTSMTP host for outgoing mail
--outgoing-port <port>MAILDEV_OUTGOING_PORTSMTP port for outgoing mail
--outgoing-user <user>MAILDEV_OUTGOING_USERSMTP user for outgoing mail
--outgoing-pass <password>MAILDEV_OUTGOING_PASSSMTP password for outgoing mail
--outgoing-secureMAILDEV_OUTGOING_SECUREUse SMTP SSL for outgoing mail
--auto-relay [email]MAILDEV_AUTO_RELAYUse auto-relay mode. Optional relay email address
--auto-relay-rules <file>MAILDEV_AUTO_RELAY_RULESFilter rules for auto relay mode
--incoming-user <user>MAILDEV_INCOMING_USERSMTP user for incoming mail
--incoming-pass <pass>MAILDEV_INCOMING_PASSSMTP password for incoming mail
--incoming-secureMAILDEV_INCOMING_SECUREUse SMTP SSL for incoming emails
--incoming-cert <path>MAILDEV_INCOMING_CERTCert file location for incoming SSL
--incoming-key <path>MAILDEV_INCOMING_KEYKey file location for incoming SSL
--web-ip <ip address>MAILDEV_WEB_IPIP Address to bind HTTP service to, defaults to --ip
--web-user <user>MAILDEV_WEB_USERHTTP user for GUI
--web-pass <password>MAILDEV_WEB_PASSHTTP password for GUI
--base-pathname <path>MAILDEV_BASE_PATHNAMEBase path for URLs
--disable-webMAILDEV_DISABLE_WEBDisable the use of the web interface. Useful for unit testing
--hide-extensions <extensions>MAILDEV_HIDE_EXTENSIONSComma separated list of SMTP extensions to NOT advertise (SMTPUTF8, PIPELINING, 8BITMIME)
-o, --openOpen the Web GUI after startup
-v, --verbose
--silent
--log-mail-contentsLog a JSON representation of each incoming mail

API

MailDev can be used in your Node.js application. For more info view theAPI docs.

constMailDev=require("maildev");constmaildev=newMailDev();maildev.listen();maildev.on("new",function(email){// We got a new email!});

MailDev also has aREST API. For more infoview the docs.

Outgoing email

Maildev optionally supports selectively relaying emails to an outgoing SMTP server. If you configure outgoingemail with the --outgoing-* options you can click "Relay" on an individual email to relay through MailDev outto a real SMTP service that will *actually* send the email to the recipient.

Example:

$ maildev --outgoing-host smtp.gmail.com \          --outgoing-secure \          --outgoing-user 'you@gmail.com' \          --outgoing-pass '<pass>'

Auto relay mode

Enabling the auto relay mode will automatically send each email to it's recipientwithout the need to click the "Relay" button mentioned above.The outgoing email options are required to enable this feature.

Optionally, you can specify a single email address to which Maildev will forwardall emails instead of the original recipient. For example, using--auto-relay you@example.com will forward all emails to that addressautomatically.

Additionally, you can pass a valid json file with additional configuration forwhich email addresses you would like toallow ordeny. The last matchingrule in the array will be the rule MailDev will follow.

Example:

$ maildev --outgoing-host smtp.gmail.com \          --outgoing-secure \          --outgoing-user 'you@gmail.com' \          --outgoing-pass '<pass>' \          --auto-relay \          --auto-relay-rules file.json

Rules example file:

[{"allow":"*"},{"deny":"*@test.com"},{"allow":"ok@test.com"},{"deny":"*@utah.com"},{"allow":"johnny@utah.com"}]

This would allowangelo@fbi.gov,ok@test.com,johnny@utah.com, but denybodhi@test.com.

Configure your project

Configure your application to send emails via port1025 and openlocalhost:1080 in your browser.

Nodemailer (v1.0+)

// We add this setting to tell nodemailer the host isn't secure during devprocess.env.NODE_TLS_REJECT_UNAUTHORIZED="0";consttransport=nodemailer.createTransport({port:1025,// other settings...});

Django -- AddEMAIL_PORT = 1025 in your settings file[source]

Rails -- config settings:

config.action_mailer.delivery_method=:smtpconfig.action_mailer.smtp_settings={address:"localhost",port:1025,enable_starttls_auto:false}

Drupal -- Install and configureSMTP module or use a library likeSwiftMailer.

Spring Boot -- configuration:
in application.properties file:

spring.mail.host=localhost #where the smtp server is runningspring.mail.port=1025spring.mail.username=no-reply@gmail.comspring.mail.properties.mail.smtp.starttls.enable=truespring.mail.properties.mail.smtp.starttls.required=truespring.mail.properties.mail.smtp.auth=truespring.mail.properties.mail.smtp.connectiontimeout=5000spring.mail.properties.mail.smtp.timeout=5000spring.mail.properties.mail.smtp.writetimeout=5000

Or in application.yml file:

spring:    mail:        properties:            mail:                smtp:                    starttls:                        enable: true                        required: true                    auth: true                    connectiontimeout: 5000                    timeout: 5000                    writetimeout: 5000        host: localhost        port: 1025

Features

  • Toggle between HTML, plain text views as well as view email headers
  • Test responsive emails with resizable preview pane available for various screen sizes
  • Ability to receive and view email attachments
  • WebSocket integration keeps the interface in sync once emails are received
  • Command line interface for configuring SMTP and web interface ports
  • Ability to relay email to an upstream SMTP server

Ideas

If you're using MailDev and you have a great idea, I'd love to hear it. If you're not using MailDev because it lacks a feature, I'd love to hear that too. Add an issue to the repohere.

Contributing

Any help on MailDev would be awesome. There is plenty of room for improvement. Feel free tocreate a Pull Request from small to big changes.

To runMailDev during development:

npm installnpm run dev

The "dev" task will run MailDev using nodemon and restart automatically whenchanges are detected. On*.scss file save, the css will also be recompiled.Usingtest/send.js, a few test emails will be sent every time the applicationrestarts.

If you want to debug you can use thenodemon debug profile in VSCode. To change arguments or environment variables edit the.vscode\launch.json.

The project uses theJavaScript Standard coding style.To lint your code before submitting your PR, runnpm run lint.

To run the test suite:

$ npm test

Thanks

MailDev is built on using great open source projects includingExpress,AngularJS,Font Awesome and two great projects fromAndris Reinman:smtp-serverandmailparser.Many thanks to Andris as his projects are the backbone of this app and toMailCatcher for the inspiration.

Additionally, thanks to all the awesomecontributorsto the project.

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp