首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在码头容器内运行时找不到Sendmail主机

在码头容器内运行时找不到Sendmail主机
EN

Stack Overflow用户
提问于 2019-03-08 18:14:02
回答 1查看 3K关注 0票数 2

我试图从码头集装箱发送电子邮件。我所能看到的最简单的一行是从earlier堆栈溢出响应中看到的:

代码语言:javascript
复制
docker run --rm --net="host" php:fpm-alpine sh -c 'echo "Subject: test" | sendmail -v your@mail.com'

我将your@mail.com更改为gmail地址并运行命令。问题是,我现在在我的终端中得到了这个输出:

代码语言:javascript
复制
sendmail: recv:'220 mail.example.com ESMTP ready'
sendmail: send:'EHLO linuxkit-025000000001'
sendmail: recv:'250 mail.example.com'
sendmail: linuxkit-025000000001: Host not found

,为了获得一个简单的示例邮件,我需要做什么不同的工作?

我想我已经接近了,因为我正在从sendmail获得输出。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-03-08 23:19:07

Sendmail试图通过位于这里的SMTP服务器转发您的电子邮件:mail.example.com.。这是此映像上sendmail的内置默认配置。

您要做的是传递sendmail的google SMTP配置,如下所示:

代码语言:javascript
复制
echo "Subject: test" | sendmail -v -f your@mail.com -au<your-gmail-account> -ap<your-gmail-password> -H 'openssl s_client -quiet -tls1 -connect smtp.gmail.com:465' your@mail.com

以下方面的实际例子:

  • gmail帐号: your@gmail.com
  • gmail密码: 123456

会像这样:

代码语言:javascript
复制
echo "Subject: test" | sendmail -v -f your@mail.com -auyour@gmail.com -ap123456 -H 'openssl s_client -quiet -tls1 -connect smtp.gmail.com:465' your@mail.com

sendmail --帮助

供参考,这里是sendmail --help。您可以从正在使用的图像中获取它:

代码语言:javascript
复制
docker run --rm php:fpm-alpine sendmail --help
代码语言:javascript
复制
BusyBox v1.29.3 (2019-01-24 07:45:07 UTC) multi-call binary.

Usage: sendmail [-tv] [-f SENDER] [-amLOGIN 4<user_pass.txt | -auUSER -apPASS]
                [-w SECS] [-H 'PROG ARGS' | -S HOST] [RECIPIENT_EMAIL]...

Read email from stdin and send it

Standard options:
        -t              Read additional recipients from message body
        -f SENDER       For use in MAIL FROM:<sender>. Can be empty string
                        Default: -auUSER, or username of current UID
        -o OPTIONS      Various options. -oi implied, others are ignored
        -i              -oi synonym, implied and ignored

Busybox specific options:
        -v              Verbose
        -w SECS         Network timeout
        -H 'PROG ARGS'  Run connection helper. Examples:
                openssl s_client -quiet -tls1 -starttls smtp -connect smtp.gmail.com:25
                openssl s_client -quiet -tls1 -connect smtp.gmail.com:465
                        $SMTP_ANTISPAM_DELAY: seconds to wait after helper connect
        -S HOST[:PORT]  Server (default $SMTPHOST or 127.0.0.1)
        -amLOGIN        Log in using AUTH LOGIN (-amCRAM-MD5 not supported)
        -auUSER         Username for AUTH
        -apPASS         Password for AUTH

If no -a options are given, authentication is not done.
If -amLOGIN is given but no -au/-ap, user/password is read from fd #4.
Other options are silently ignored; -oi is implied.
Use makemime to create emails with attachments.
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55068797

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档