

#!/bin/bash
# 이메일 발신자, 수신자, 제목 및 내용 설정
from_email="sender@naver.com"
from_pw="password"
smtphost="smtp.naver.com"
to_email="recipient@example.com"
subject="Test email with embedded image"
body="This is a test email with an embedded image."
boundary="boundary_string"
# 이미지 파일 경로 설정
image_path="/path/to/image.png"
# 이메일 본문에 이미지를 추가
body_with_image="From: $from_email\r\nTo: $to_email\r\nSubject: $subject\r\nMIME-Version: 1.0\r\nContent-Type: multipart/related; boundary=$boundary\r\n\r\n--$boundary\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n<html><body><p>$body</p><img src=\"cid:image1\"></body></html>\r\n--$boundary\r\nContent-Type: image/png\r\nContent-Transfer-Encoding: base64\r\nContent-ID: <image1>\r\nContent-Disposition: inline; filename=\"image.png\"\r\n\r\n$(base64 -w 0 $image_path)\r\n--$boundary--"
echo -e "$body_with_image" > email.txt
# SMTP 서버에 연결하고 이메일 발송
# SSL연결할 경우 --ssl-reqd 추가하고
# smtps프로토콜로 변경 포트는 465
curl \
--mail-from "$from_email" \
--mail-rcpt "$to_email" \
-T email.txt \
-u "$from_email:$from_pw" \
smtp://$smtphost:25
https://stackoverflow.com/questions/44728855/curl-send-html-email-with-embedded-image-and-attachment
curl : send html email with embedded image and attachment
My goal is to send an email using curl with an html body with embedded image such as : I'm sending the email like this : curl "smtp://smtp.gmail.com:587" -v \ --mail-from "sender@gmail.com"...
stackoverflow.com
https://ko.m.wikipedia.org/wiki/MIME
MIME - 위키백과, 우리 모두의 백과사전
MIME(영어: Multipurpose Internet Mail Extensions)는 전자 우편을 위한 인터넷 표준 포맷이다. 전자우편은 7비트 ASCII 문자를 사용하여 전송되기 때문에, 8비트 이상의 코드를 사용하는 문자나 이진 파일들
ko.m.wikipedia.org
[메일] “Multipart” Content-Type
출처: http://blog.naver.com/skimms/10051107325 ★ “Multipart” Content-Type Content-Type 중 하나로, 서브 타입으로 mixed, alternative, digest, related 를 갖는다. 여러 개의 독립된 섹션으로 구성된 데이터를 하나의 메
tod2.tistory.com
'# Script > Bash' 카테고리의 다른 글
[bash]텔넷 접속 후 명령실행(결과 화면 저장) (0) | 2023.01.12 |
---|---|
[bash]변수 내 문자열 길이 확인 (0) | 2023.01.12 |
bash 스크립트 if문 옵션 정리 (0) | 2022.07.07 |
[bash]오래된 로그 정리 (0) | 2022.03.25 |
[bash]파라미터(인자값) 처리 (0) | 2015.08.16 |
안녕하세요. 이곳은 IT위주의 잡다한 정보를 올려두는 개인 블로그입니다.
포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!