smalot/sendmail-smtp

用于通过SMTP发送邮件的Sendmail包装器

安装: 21

依赖: 0

建议: 1

安全性: 0

星标: 10

关注者: 4

分支: 3

开放问题: 0

类型:项目

v0.2.0 2017-01-13 22:50 UTC

This package is not auto-updated.

Last update: 2024-09-14 20:40:51 UTC


README

Latest Stable Version Latest Unstable Version License composer.lock

Total Downloads Monthly Downloads Daily Downloads

PHP包装器,用于替换默认的/usr/sbin/sendmail以添加smtp支持。

为基本mail函数添加smtp支持。

配置

下载命令行工具

首先,下载最新的二进制文件

wget https://github.com/smalot/sendmail-smtp/releases/download/v0.1.0/sendmail.phar

然后启用执行标志

chmod +x sendmail.phar

通过显示版本检查是否工作

./sendmail.phar list

更新php.ini

编辑cliapache或两者php.ini文件。

# Set the full path to the phar command line tool.
sendmail_path = "/path/to/phar/sendmail.phar"

sendmail_pathPHP_INI_SYSTEM类型的可更改配置项,这意味着您只能在php.ini文件或httpd.conf文件中更改它。

配置文件

存储配置的文件:/etc/sendmail-smtp.yml

但是,您可以通过在sendmail_path值中指定它,将配置文件放在另一个文件夹中。

sendmail_path = "/path/to/phar/sendmail.phar -f /config/folder/sendmail.yml"

详细说明

# SMTP hosts.
# Either a single hostname or multiple semicolon-delimited hostnames.
# You can also specify a different port
# for each host by using this format: [hostname:port]
# (e.g. "smtp1.example.com:25;smtp2.example.com").
# You can also specify encryption type, for example:
# (e.g. "tls://smtp1.example.com:587;ssl://smtp2.example.com:465").
# Hosts will be tried in order.
host: 127.0.0.1

# The default SMTP server port.
port: 25

# Whether to use SMTP authentication.
# Uses the Username and Password properties.
auth: false

# SMTP username.
username: ~

# SMTP password.
password: ~

# SMTP auth type.
# Options are CRAM-MD5, LOGIN, PLAIN, NTLM, XOAUTH2, attempted in that order if not specified.
auth_type: ~

# What kind of encryption to use on the SMTP connection.
# Options: '', 'ssl' or 'tls'
secure: ~

# Whether to enable TLS encryption automatically if a server supports it,
# even if `secure` is not set to 'tls'.
# Be aware that in PHP >= 5.6 this requires that the server's certificates are valid.
auto_tls: ~

# SMTP realm.
# Used for NTLM auth
realm: ~

# SMTP workstation.
# Used for NTLM auth
workstation: ~

# The SMTP server timeout in seconds.
# Default of 5 minutes (300sec) is from RFC2821 section 4.5.3.2
timeout: 300

# Options array passed to stream_context_create when connecting via SMTP.
# @see http://nl1.php.net/manual/en/function.stream-context-create.php
options: ~

# SMTP class debug output mode.
# Debug output level.
# Options:
# * `0` No output
# * `1` Commands
# * `2` Data and commands
# * `3` As 2 plus connection status
# * `4` Low-level data output
debug: 0

示例配置文件

Gmail

host: smtp.gmail.com
port: 587
username: mail@example.tld
password: xxxxxxxxxx
auth: true

1and1

host: smtp.1und1.de
port: 587
username: mail@example.tld
password: xxxxxxxxxx
auth: true

SMTP服务器Docker

https://github.com/smalot/smtp-server-docker

host: 127.0.0.1
port: 8025
auth: false