
コマンドラインからメールを送信するにはどうすればいいですか?
答え1
インストールSMTP
:
sudo apt-get install ssmtp
ssmtp 設定ファイルを編集します。
gksu gedit /etc/ssmtp/ssmtp.conf
次のテキストを追加します。
[email protected] mailhub=smtp.gmail.com:465 rewriteDomain=gmail.com AuthUser=username AuthPass=password FromLineOverride=YES UseTLS=YES
ssmtp を実行し、受信者の電子メール アドレスを指定します。
ssmtp [email protected]
メッセージの詳細を次のように入力します。
To: [email protected] From: [email protected] Subject: Sent from a terminal! Your content goes here. Lorem ipsum dolor sit amet, consectetur adipisicing. (Notice the blank space between the subject and the body.)
Ctrl送信するには+を押してくださいD。
次のようにテキストをファイルに入れて送信することもできます。
ssmtp [email protected] < filename.txt
答え2
ほとんどの場合、SMTP サーバーを設定する必要はなく、mail
コマンドラインから簡単に使用できます (まだ存在しない場合は、 でインストールしますsudo apt-get install mailutils
)。 (または、sendmail が設定されているサーバーを使用している場合など)
marco@dagobah:~$ mail -v [email protected]
Subject: Hello World!
This is an email to myself.
Hope all is well.
.
Cc:
メッセージを 1.
行で終了します。その場合、情報を入力するか空白のままにするかをmail
尋ねられ、次に実行しようとしている処理に関する追加情報と、メール サーバーへの接続、送信、およびデータの受信の処理の詳細が出力されます。Cc:
mail
答え3
apt-get install sendemail
使用法:
sendemail -f [email protected] -t [email protected] -u subject -m "message" -s smtp.gmail.com:587 -o tls=yes -xu [email protected] -xp gmailpassword
コマンドラインでパスワードを指定したくない場合は (通常はそうしない方がよいでしょう)、そのパラメータを省略できます。その場合、sendemail はパスワードの入力を要求し、それを画面に表示しますが、少なくともコマンドラインの履歴には残りません。
答え4
メールを送信するには MTA が必要です。そのためには postfix を使用します:
sudo apt-get install postfix
メールを送信するには:
echo "test message" | mailx -s 'test subject' [email protected]