일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 |
- Windows 10
- 딥러닝
- YouTube 8M
- ubuntu
- pyTorch
- linux
- Anaconda
- python
- install
- FIle
- urllib
- Deep Learning
- windows
- dlib
- shakeratos
- CUDA
- error
- python3
- TensorFlow
- Jupyter notebook
- dataset
- keras
- object detection
- colab
- face_recognition
- raspberry pi
- download
- gpu memory
- colaboratory
- ppc64le
- Today
- Total
Shakerato
gmail 계정 연동 python smtplib로 이메일 전송하기 본문
# gamil_python_test.py import smtplib from email.mime.text import MIMEText
def send_email(senders='test@gmail.com', receiver='test@gmail.com', content='Hello.'): print('email 전송') s = smtplib.SMTP(host='smtp.gmail.com', port=int(587)) # TLS:587 SSL:465 s.ehlo() # say Hello s.starttls() # TLS 보안 시작 s.login(user=str('USER ID'), password=str('USER PASSWORD'), initial_response_ok=True) # 로그인 인증 print('login 완료') msg = MIMEText(str(content)) # 보낼 메시지 설정 msg['Subject'] = str('TITLE 입력') msg['To'] = receiver s.sendmail(senders, receiver, msg.as_string()) # 메일 보내기 s.quit() # 세션 종료
print('email 전송 완료') send_email() |
gmail의 아이디와 패스워드가 맞음에도
"smtplib.SMTPAuthenticationError" 에러가 나는 경우
아래 URL 통해 "보안 수준이 낮은 앱 허용: 사용" 체크
If you got "smtplib.SMTPAuthenticationError",
you need to check which allow low security app button in the below URL.
https://myaccount.google.com/lesssecureapps?pli=1
로그인 - Google 계정
하나의 계정으로 모든 Google 서비스를 Google 계정으로 로그인
accounts.google.com