
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
메일 안보내지고, 계속 에러. 메세지 나옴.
import smtplib
import pandas as pd
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
# 엑셀 파일에서 데이터 읽기
file_path = '/content/customer_data_test_ㅂㅅㅇ.xlsx'
sheet_name = 'test_email'
customer_data = pd.read_excel(file_path, sheet_name=sheet_name)
# SMTP 서버 설정
smtp_host = 'smtp.gmail.com'
smtp_port = 587 # SMTP 포트 (일반적으로 587 또는 465)
smtp_username = 'ord@gmail.com' # SMTP 서버에 로그인할 이메일 주소
smtp_password = '본인올바른 비번사용' # SMTP 서버에 로그인할 이메일 비밀번호
# 이메일 보내는 함수 정의
def send_email(to_email, subject, body):
msg = MIMEMultipart()
msg['From'] = smtp_username
msg['To'] = to_email
msg['Subject'] = subject
msg.attach(MIMEText(body, 'plain'))
# SMTP 서버에 연결
server = smtplib.SMTP(smtp_host, smtp_port)
server.starttls()
server.login(smtp_username, smtp_password)
# 이메일 보내기
server.send_message(msg)
server.quit()
# 고객에게 이메일 보내기
for index, row in customer_data.iterrows():
customer_name = row['name']
customer_email = row['e-mail']
email_subject = '제목' # 이메일 제목을 입력하세요
email_body = f'안녕하세요, {customer_name}님에게 보내는 메일 내용을 입력하세요.' # 이메일 내용을 입력하세요
try:
send_email(customer_email, email_subject, email_body)
print(f"{customer_name}님에게 이메일을 성공적으로 보냈습니다.")
except Exception as e:
print(f"{customer_name}님에게 이메일을 보내는 중 오류가 발생했습니다: {str(e)}")
에러메세지
박수연1님에게 이메일을 보내는 중 오류가 발생했습니다: (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 f89-20020a0284e2000000b00470efc68bd3sm354838jai.174 - gsmtp')
박수연2님에게 이메일을 보내는 중 오류가 발생했습니다: (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 b15-20020a6be70f000000b007c3ec06ccd0sm256283ioh.25 - gsmtp')
박수연3님에게 이메일을 보내는 중 오류가 발생했습니다: (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 m10-20020a056638260a00b004712a59a3b6sm359105jat.155 - gsmtp')
박수연4님에게 이메일을 보내는 중 오류가 발생했습니다: (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 v14-20020a056e02164e00b00363c5391adbsm352054ilu.77 - gsmtp')
박수연5님에게 이메일을 보내는 중 오류가 발생했습니다: (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 l18-20020a056638145200b0046f02c793a6sm348092jad.52 - gsmtp')
앱비밀번호는 아이에 설정할수 있는 옵션에 안나옴

