postfix를 통해 전자 메일을 보낼 때 헤더에는 항상 제거 할 추가 홉이 하나 있습니다. 여기에 헤더는 다음과 같습니다postfix를 통해 python을 사용하여 전자 메일 보내기
From [email protected] Sat Aug 20 18:40:58 2016
Return-Path: <[email protected]>
X-Original-To: [email protected]
Delivered-To: [email protected]
Received: from mta.emailcab.com (mta.emailcab.com [52.58.223.55])
by prosolutionmail.com (Postfix) with ESMTP id 75F5B23C0AC7
for <[email protected]>; Sat, 20 Aug 2016 18:40:58 +0200 (CEST)
Authentication-Results: prosolutionmail.com; dkim=pass
reason="2048-bit key; unprotected key"
header.d=mta.emailcab.com [email protected]
header.b=mXAsVoW+; dkim-adsp=pass; dkim-atps=neutral
Received: from [127.0.0.1] (localhost [127.0.0.1])
by mta.emailcab.com (Postfix) with ESMTP id 0585383189
for <[email protected]>; Sat, 20 Aug 2016 16:40:58 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mta.emailcab.com;
s=key1; t=1471711258;
bh=BUn1x+fCFHl9Q+e98U5epKcL5xZNNNU3Lq/zNz0IMnI=;
h=Subject:From:To:Date:From;
b=mXAsVoW+IYePOdDe1d7OyQdYpRzNoKdYclLEv/wXm3dDjJulDMfr5HM274U1ypNNs
OCqK5TNRo4UMrFqIcU38BVjOIwN3gPOStxs3jSEmoWLXynIAuclbNew692P2KY7jkn
oU7lhPZ1CwBln+qEKKXbyuiXtRmbA2Qp1pvLu+R9T/WfPzWiVhe+2CPq9ob3j3mwBW
oBjLNvmbm74eenMKxv8G47FBi7HS4+9eSuUI9TVV0fb/qZwNHwumpFeTA5DPRzkQPM
u5imAbdz5GqXxs4wo4UXTpWEb7dSkzJu7/2ebLshCnnuSoN8HV5j79GEoidyzmqEpC
saF1XA+rJvKwg==
Content-Type: multipart/alternative; boundary="===============5118095836845773678=="
MIME-Version: 1.0
Subject: =?utf-8?b?0JrQsNC6INC00L7QsdGA0LDRgtGM0YHRjyDQtNC+INCb0YzQstC+0LLQsD8=?=
From: [email protected]
To: [email protected]
Message-Id: <[email protected]>
Date: Sat, 20 Aug 2016 16:40:58 +0000 (UTC)
당신이 볼 수 있듯이, 두 개의 "수신"헤더, 발신 IP 중 하나와 로컬 하나있다. 공용 IP 만 볼 수 있도록 전자 메일을 보내려면 어떻게합니까?
그것은 파이썬에 고정되어서는 안import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.image import MIMEImage
from email.header import Header
smtp = smtplib.SMTP()
smtp.connect('localhost')
msgRoot = MIMEMultipart("alternative")
msgRoot['Subject'] = Header("Subject subject", "utf-8")
msgRoot['From'] = "[email protected]"
msgRoot['To'] = "[email protected]"
text = MIMEText(open('template.txt', 'r').read(), "plain", "utf-8")
msgRoot.attach(text)
html = MIMEText(open('template.html', 'r').read(), "html", "utf-8")
msgRoot.attach(html)
smtp.sendmail("[email protected]", "[email protected]", msgRoot.as_string())
myhostname은 mail.example.com입니다. 파이썬에서 sendmail 명령으로 이메일을 보낼 수 있다면 어떨까요? 로컬 smtp에 연결하는 대신 sendmail 명령과 msgRoot.as_string() 값을 사용하여 프로세스를 실행하십시오. – offline15
'sendmail'에는 후위가 필요합니다. –
sendmail -S test [email protected] sendmail : 유효하지 않은 옵션 - 'S' sendmail : 치명적인 : open /etc/postfix/main.cf : 그런 파일이나 디렉토리가 없습니다. –