大网数据广告活动
服务器运维问答

Authenticated SMTP with sendmail on command line

· 52CE 我爱测

we are sending emails using sendmail on the command line, with a command such as : cat <email_contents> | sendmail -t the <email_contents> contains fields such as sender, recipient etc.: To: [email omitted] Subject: Testing From:…

问题原文

原帖链接 · olivierg · CC BY-SA 4.0

we are sending emails using sendmail on the command line, with a command such as :

cat <email_contents> | sendmail -t

the <email_contents> contains fields such as sender, recipient etc.:

To: [email omitted]
Subject: Testing
From: [email omitted]

as well as a huge file, attachments etc.

we now need to use Authenticated SMTP (pass a login & password argument to authenticate against the SMTP server).

is there a way to do that with this method ? (using sendmail arguments or modifying the email_contents taking in consideration the following elements:

  1. NOT using mailx or any other mail client. we need to keep using sendmail from the commandline
  2. NOT amending the sendmail configuration files (sendmail.cf)

thanks again regards,

已采纳解答

原帖链接 · bob · CC BY-SA 4.0

As the manual says

"sendmail is not intended as a user interface routine".

The capabilities of the sendmail command to send mail stopped evolving well before SMTP authentication was invented.

When your environment is moving out of the stone-age and starts requiring newfangled technology like authentication and TLS, then you will need to get rid of your rocks to keep up.

Your options are exactly what you don't want to do, and you will need to upgrade your tools and practices to keep up with the times:

  • Either use a more advanced mail submission agent such as for example
    • mailx
    • the "drop in" sendmail command replacement ssmtp that does have smtp auth support.
    • or others.
  • install and configure a local MDA (like sendmail, postfix, exim etc.) to do the more advanced stuff that the sendmail command can't do for you and keep using the sendmail command

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2021-08-25)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。