camelot/smtp-dev-server

开发 SMTP 模拟服务器

0.0.4 2022-09-23 08:52 UTC

This package is auto-updated.

Last update: 2024-09-06 07:38:44 UTC


README

仅供开发环境使用

一个简单且非常模拟的SMTP服务器,用于开发/测试目的。因为,为什么不呢。

功能

  • 可以接受并存储有效RFC822/RFC2822电子邮件的SMTP服务器
  • HTTP服务器/站点作为接收消息的客户端界面

警告:不要将运行中的服务器端口暴露给公开网络,不要以root或管理员用户身份运行!这些服务器中没有任何安全功能。

安装

全局

$ composer global require camelot/smtp-dev-server

作为项目的开发依赖项

$ composer require --dev camelot/smtp-dev-server

配置

配置通过环境变量处理。

SMTP_LOG_LEVEL=debug
SMTP_LOG_FILE="/path/to/smtp.log"
SMTP_SPOOL_DIR="/path/to/spool"
HTTP_LOG_LEVEL=debug
HTTP_LOG_FILE="/path/to/http.log"

如果您正在克隆此存储库,请参阅此目录中的.env文件以获取示例,您可以创建一个.env.local文件来覆盖.env文件中的任何值。

使用

两个服务器都有两个输出目标,控制台和PSR记录器。

控制台输出级别通过传递命令行上的-v-vv-vvv作为选项来管理。

记录器输出通过用于内部配置记录器的环境变量来管理。

例如

$ SMTP_LOG_LEVEL=debug vendor/bin/smtp-dev-server -vvv

服务器

image

要启动服务器,只需运行

$ vendor/bin/smtp-dev-server

这将输出内部信息到STDOUT。您可以使用以下命令选项指定详细程度。

可以通过发送信号停止服务器,例如CTRL+C

参数

  backing          Storage type (null, memory, mailbox) [default: "mailbox"]

选项

  -i, --ip=IP            TCP/IP address [default: "127.0.0.1"]
  -p, --port=PORT        Port to listen on [default: 2525]
  -r, --retries=RETRIES  Number of times to retry connecting to the server socket address if it is currently in use [default: 10]
  -h, --help             Show help
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

客户端

image image

要启动服务器,只需运行

$ vendor/bin/smtp-dev-client

这将输出内部信息到STDOUT。您可以使用以下命令选项指定详细程度。

可以通过发送信号停止服务器,例如CTRL+C

参数

  backing          Storage type (null, memory) [default: "null"]

选项

  -i, --ip=IP            TCP/IP address [default: "127.0.0.1"]
  -p, --port=PORT        Port to listen on [default: 2580]
  -r, --retries=RETRIES  Number of times to retry connecting to the server socket address if it is currently in use [default: 10]
  -h, --help             Show help
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

打开(默认)http://127.0.0.1:2580以查看和管理通过SMTP服务器组件接收到的消息。