터미널에서 이메일을 보내는 방법
Linux/MacOS 단말기에서 이메일을 보내는 방법이 있다는 것은 알지만, 그 방법에 대한 적절한 문서를 찾을 수 없을 것 같습니다.
기본적으로 파일이 변경될 때마다 알려주는 bash 스크립트에 필요합니다.
echo "this is the body" | mail -s "this is the subject" "to@address"
터미널로 이동하여 입력man mail
도움을 청합니다.
를 설정할 필요가 있습니다.SMTP
업:
http://hints.macworld.com/article.php?story=20081217161612647
다음 항목도 참조하십시오.
http://www.mactricksandtips.com/2008/09/send-mail-over-your-network.html
예:
mail -s "hello" "example@example.com" <<EOF
hello
world
EOF
다음 주소로 이메일을 보냅니다.example@example.com
주제를 가지고hello
그리고 메시지
안녕하세요.
세계
아마도 가장 간단한 방법은curl
이를 위해 추가 패키지를 설치할 필요가 없으며 요청으로 직접 구성할 수 있습니다.
다음은 gmail smtp 서버를 사용하는 예입니다.
curl --url 'smtps://smtp.gmail.com:465' --ssl-reqd \
--mail-from 'from-email@gmail.com' \
--mail-rcpt 'to-email@gmail.com' \
--user 'from-email@gmail.com:YourPassword' \
-T <(echo -e 'From: from-email@gmail.com\nTo: to-email@gmail.com\nSubject: Curl Test\n\nHello')
제목(경보 메시지와 같이)만 필요한 경우 다음 작업을 수행합니다.
mailx -s "This is all she wrote" < /dev/null "myself@myaddress"
리눅스에서 파일을 첨부하려는 경우
echo 'mail content' | mailx -s 'email subject' -a attachment.txt username@stackoverflow.com
Mac OS 또는 Linux OS의 터미널에 이 코드를 입력합니다.
mail -s (subject) (receiversEmailAddress) <<< "how are you?"
예를 들어, 이것을 시도해 보세요.
mail -s "hi" abc@example.com <<< "how are you?"<br>
SMTP 호스트 및 Gmail의 경우 Swaks를 사용합니다.-> https://easyengine.io/tutorials/mail/swaks-smtp-test-tool/
Mac의 경우:
brew install swaks
swaks --to user@example.com --server smtp.example.com
나는 스와크가 최고라고 생각해.여기에서는, 포토 25 로 TLS 암호화를 사용하는 보다 복잡한 예를 나타냅니다.
swaks --from john.smith@mydomain.com \
--h-From: '"John Smith" <john.smith@mydomain.com>' \
--h-Subject: 'Subject of message' \
--auth LOGIN --auth-user mylogin --auth-pass mypass \
--to someone@otherdomain.com \
--server smtp.example.com --port 25 -tls \
--add-header 'Content-Type: text/plain; charset="utf-8"'
여러 줄의 메시지를 보낼 수 있었습니다.mailx
다음 셸 스크립트를 사용합니다.
#!/bin/sh
MSG_FROM=zac@server.it
MSG_TO="zac@gmail.com"
MSG_SUBJ="Test"
SMTP_HOST="relay.zac.it"
MSG_BODY=(
"Line one"
""
"Line two")
printf '%s\n' "${MSG_BODY[@]}" | mailx -v -s "$MSG_SUBJ" -S smtp="smtp://$SMTP_HOST" -S from=$MSG_FROM $MSG_TO
Red Hat Enterprise Linux Server 릴리즈 6.4 (Santiago)를 사용하고 있다.
언급URL : https://stackoverflow.com/questions/8260858/how-to-send-email-from-terminal
'programing' 카테고리의 다른 글
문자열에 쓰기Panda Excelwriter를 사용한 IO 객체 (0) | 2023.04.11 |
---|---|
Python 3.x와 2.x를 같은 Windows 컴퓨터에 설치할 수 있습니까? (0) | 2023.04.11 |
왜 이 단순한 Angular는JS ng-show가 안 돼요? (0) | 2023.04.06 |
리다이렉트 기능이 있는 스프링 부트 (1페이지 angular 2) (0) | 2023.04.06 |
열거를 문자열로 직렬화 (0) | 2023.04.06 |