Home Security Mailhog的安装方式 Install Mailhog
Post
Cancel

Security Mailhog的安装方式 Install Mailhog

refer to:
https://www.lullabot.com/articles/installing-mailhog-for-ubuntu

只看官方文档不行,还是需要看上面的参考文档。

MailHog是一个发送邮件的中间商。

1. 安装go

2. 安装 MailHog

go install github.com/mailhog/MailHog@latest
go install github.com/mailhog/mhsendmail@latest

然后把 对应的两个 命令copy到 path文件夹下:

cp /root/go/bin/MailHog /usr/local/bin/mailhog
cp /root/go/bin/mhsendmail /usr/local/bin/mhsendmail

3. 安装php

apt install php7.2-cli

配置文件在  /etc/php/7.2/cli

在这个文件中,设置这个内容:

sendmail_path = /usr/local/bin/mhsendmail

4. 运行:

php -r "\$from = \$to = 'iamyates.^Cina.com'; \$x = mail(\$to, 'subject'.time(), 'Hello World2222', 'From: '. \$from); var_dump(\$x);"

上面的命令, 定义了 from, to 两个变量, 并且调用mail 方法。 (该方法使用了sendmail配置)

5. 运行 MailHog:

mailhog \
  -api-bind-addr 127.0.0.1:8025 \
  -ui-bind-addr 127.0.0.1:8025 \
  -smtp-bind-addr 127.0.0.1:1025

6. 打开MailHog, 可以看到啥都没有:

7. 运行php命令,发送邮件:

php -r "\$from = \$to = 'iamyates.^Cina.com'; \$x = mail(\$to, 'subject'.time(), 'Hello World2222', 'From: '. \$from); var_dump(\$x);"

bool(true)     # => 能立刻看到这个,就说明成功了。

8. 进入到列表:

点击一个邮件:

点击这个按钮,设置release 选项:

This post is licensed under CC BY 4.0 by the author.