커뮤니티
포인트
쿠폰
내 강의실
국비 신청 내역
증명서
계정
로그아웃
학습 질문
개발 일지
나의 활동
답변 완료
4-5 이메일 전송 문의
[왕초보] ChatGPT 300% 활용하기 v0
4주차
북마크
유*수
댓글
2
추천
0
조회수
4
조회수
4
답변 완료

* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.

* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.


안녕하세요 이메일 전송 중 오류 발생이 되어 구글 이메일 부계정이 로그인이 안됩니다.. 본 계정으로 연습하다 본계정까지 로그인이 안될 것 같아 질문드립니다.

아래와 같이 메일을 전송하려고 하는데 오류가 발생되더라고요 어떤문제가 있는지 질문드립니다.


  1. 엑셀파일 다운로드 (customer_data_test.xlsx)
  2. 엑셀파일 클릭 후 test_name_email 파일에 name, email 주소 입력
  3. colab에 엑셀파일 업로드 (customer_data_test.xlsx)
  4. colab에서 아래와 같이 smtp_username, password 는 동영상 강의대로 입력하였습니다.



import openpyxl

import smtplib

from email.mime.text import MIMEText

from email.mime.multipart import MIMEMultipart


# Gmail SMTP 서버 설정

smtp_server = 'smtp.gmail.com'

smtp_port = 587

smtp_username = '입력했음'

smtp_password = '입력했음'


# Excel 파일에서 이름과 이메일 추출

wb = openpyxl.load_workbook('customer_data_test.xlsx')

ws = wb['test_name_email']


name_list = []

email_list = []


for row in ws.iter_rows(min_row=2, values_only=True):

    name = row[0]

    email = row[1]

    name_list.append(name)

    email_list.append(email)


# Gmail 서버 연결

with smtplib.SMTP(smtp_server, smtp_port) as smtp:

    smtp.starttls()

    smtp.login(smtp_username, smtp_password)


    for name, email in zip(name_list, email_list):

        # 메일 제목, 본문 내용 작성

        mail_subject = f'[{name}] 자그마한 선물을 받으세요!'

        mail_body = f'안녕하세요 {name}님,\n\n저희 앱을 이용해주셔서 감사합니다. {name}님이 우리 앱에 10번 이상 로그인하시면 자그마한 선물을 드립니다! 하루에 최대 1번 로그인 가능합니다. 많은 이용 부탁드립니다.\n\n감사합니다.\n\n- salemale 팀'


        # 메일 생성

        message = MIMEMultipart()

        message['From'] = smtp_username

        message['To'] = email

        message['Subject'] = mail_subject


        # 메일 본문 추가

        message.attach(MIMEText(mail_body))


        # 메일 전송

        smtp.send_message(message)


---------------------------------------------------출력값---------------------------------------------------------------------

SMTPAuthenticationError                   Traceback (most recent call last)
<ipython-input-2-daefbd40ff13> in <cell line: 26>()
     26 with smtplib.SMTP(smtp_server, smtp_port) as smtp:
     27     smtp.starttls()
---> 28     smtp.login(smtp_username, smtp_password)
     29 
     30     for name, email in zip(name_list, email_list):


2 frames

/usr/lib/python3.10/smtplib.py in auth(self, mechanism, authobject, initial_response_ok)
    660         if code in (235, 503):
    661             return (code, resp)
--> 662         raise SMTPAuthenticationError(code, resp)
    663 
    664     def auth_cram_md5(self, challenge=None):

SMTPAuthenticationError: (535, b'5.7.8 Username and Password not accepted. For more information, go to\n5.7.8 https://support.google.com/mail/?p=BadCredentials o5-20020a056a001b4500b006e72c8ece23sm5814897pfv.191 - gsmtp')

이와 같이 나왔으며, 그다음 gmail 오류가 뜨면서 로그인 차단이 되었습니다.. 







취소
 공유
취소
댓글 0
댓글 알림
나의얼굴