私の要件は次のとおりです
- 端末からメールを送信する(バッチ処理用)
- その電子メールにPDFファイルを添付してください。 (PDFファイルは透かしを除くすべての受信者に同じです。)
- 返信アドレス指定([Eメール保護])
私は試した「Gmailを介して1行のメッセージを送信する最も簡単な答えはssmtpを使用することです」そして、いくつかのバリエーションを通して、次のようになります。
ノートブック sSMTP[19226]: 認証に失敗しました (535 5.7.8 https://support.google.com/mail/?p=BadCredentialsd13sm3920147qkj.27-gsmtp)
Google設定:
- IMAPが有効
- セキュリティレベルの低いアプリケーションの許可がオンになっています。
ssmtp.conf
私が試したすべての設定について私はそうしました。ロック解除認証コードの表示直前:
$echo "Testing...1...2...3" | ssmtp [email protected]
見ているスレッドの指定/etc/ssmtp/ssmtp.conf
設定方法についてはまだ合意がなされていません。
mailhub=smtp.gmail.com:587
VS 465UseTLS=YES
(UseSTARTTLS=Yes
または両方?)hostname=localhost
デフォルトでは、そこに配置されているすべての項目を使用します(私の場合はlaptop
)。
誰もがこの問題に対する解決策を提案し、作業中のconfファイル全体を貼り付けることができますか?
請求があります2017年のテーマ、それ:
通常のパスワードでは外部アプリケーションを使用できません。https://security.google.com/settings/security/apppasswords
そうですか? (私はできません)
代替は何ですか?
添付:
- オペレーティングシステム:Linux Mint 19タラ
- アップグレード/アップデートの前に新しくインストールしてssmtpをテストしました。
- 数年前、同じOS(以前のバージョン)を使用して電子メールを送信できました。
- AuthPassの値が正しいことを確認するには、それを使用してGoogleアカウントに手動でログインします。
ベストアンサー1
次のGoogle設定を使用してください。
IMAP enabled
Allow less secure apps is ON
解決策は、以下を設定することです。アプリケーションパスワード:
メモ: Googleのアプリケーションパスワード設定では、ssmtpを設定するアカウントに対して最初に2段階認証プロセスを有効にする必要があります。
/var/ssmtp/ssmtp.conf:
#
# Config file for sSMTP sendmail
#
# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=postmaster
# The place where the mail goes. The actual machine name is required no
# MX records are consulted. Commonly mailhosts are named mail.domain.com
# Modified 06/27/2020:
# mailhub=mail
[email protected]
[email protected]
#AuthPass=[usual gmail pwd] # aint' gonna work
AuthPass=[pwd generated by https://myaccount.google.com/apppasswords]
#UseTLS=YES
#mailhub=smtp.gmail.com:465
UseSTARTTLS=Yes
mailhub=smtp.gmail.com:587
# Where will the mail seem to come from?
#rewriteDomain=
# The full hostname
hostname=laptop
# Are users allowed to set their own From: address?
# YES - Allow the user to specify their own From: address
# NO - Use the system generated From: address
FromLineOverride=YES
ターミナルから:
$echo "Testing...1...2...3" | ssmtp [email protected]
添付:
- 説明なしで投票に反対することは見られません。
- 質問(添付ファイル)に記載されている2番目の要件の場合、
mutt
奇跡的に効果的。
2022年12月1日に更新
使っているmsmtp
から安全性の低いアプリ障害のある
- 開いている2段階認証
- 生成するアプリケーションパスワード名前= 'msmtp'を使用
- 2)を実行し
$ touch ~/.msmtprc
て使用して、次のように内容を修正します。
# content of /home/user/.msmtprc
# do: `$ chmod 600 /home/user/.msmtprc`
# gmail
account [email protected]
host smtp.gmail.com
port 587
tls on
tls_starttls on
auth on
user google-name
from [email protected]
# https://myaccount.google.com/apppasswords
password xxxxxxxxxxxxxxxx
# default account
account default : [email protected]
$ chmod 600 /home/user/.msmtp
$ echo "Testing...1...2...3" | msmtp recipient.address@domain
この内容はBCCに送信されます。ねえ交換。