
명령줄에서 메일을 보내는 방법은 무엇입니까?
답변1
설치하다ssmtp
:
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:
단일 .
온라인으로 메시지를 종료합니다. 이때 정보를 입력 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]