2021년 1월 29일 금요일

Python - Mail Sender(SMTP)

Title = Mail sending using Python

Step
1.구글 계정 설정
크롬에서 로그인 상황일때 1,2번을 차례로 누른다

보안 클릭

2단계 인증
--문자, 전화 인증중 1개를 선택해서 진행-

앱 비밀번호 생성 선택

메일, windows 컴퓨터 선택후 생성
영역의 문자를 따로 저장해둔다
*이 pw를 통해 구글 로그인이 가능하기 때문에 보안에 주의한다*


2.Code 작성
===================================
import smtplib #stmplib 패키지를 사용
from email.mime.text import MIMEText


s = smtplib.SMTP('smtp.gmail.com', 587)# TLS 보안 시작
s.starttls()# 로그인 인증
s.login('0000e-mail address0000', '0000app password0000')
msg = MIMEText('mail send test') #메일 내용
msg['Subject'] = 'send mail test'  #메일 제목
s.sendmail("00000login e-mail address0000", "0000receive e-mail address0000 ", msg.as_string())# 메일 보내기
s.quit() # 세션 종료
==============================================

3.Result




댓글 없음:

댓글 쓰기