Python/Python for Linux
[Python] Linux Sendmail을 이용한 메일 보내기
Pydole
2019. 4. 13. 22:12
- OS : CentOS 7
- Python 2.7
#!/usr/bin/python
from email.mine.text import MIMEText
from subprocess import Popen, PIPE
msg = MIMEText('Body Text')
msg['Subject'] = 'Subject Text'
msg['From'] = 'From Email Address'
msg['To'] = 'To Email Address'
p = Popen(["/usr/sbin/sendmail", "-t"], stdin=PIPE)
p.communicate(msg.as_string())
Step 1. sendmail install
# yum install sendmailyum install sendmail sendmail-cf
|
Step 2. edit /etc/mail/sendmail.mc
52 line "dnl" remove
53 line "dnl" remove
118 line "dnl" remove
Step 3. Service Start
# systemctl start sendmail
|