
* 겪고 있는 문제 상황을 최대한 자세하게 작성해주세요.
* 문제 해결을 위해 어떤 시도를 해보았는지 구체적으로 함께 알려주세요.
아래와 같이 작성후
코렙에서 작동시 정상 작동은 되나 저 메일에는 오지않는 상황을 설명 부탁합니다^^
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 = 'damiano8709@gmail.com' #여러분들의 실사용 이메일 주소
smtp_password = 'mahmpjfsqgghufcn' #여러분들의 실사용 이메일 비밀번호
# 메일 제목, 본문 내용 등 설정
mail_subject = '메일 제목'
mail_body = '메일 본문 내용'
# 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):
# 메일 생성
message = MIMEMultipart()
message['From'] = smtp_username
message['To'] = email
message['Subject'] = mail_subject
# 메일 본문 추가
message.attach(MIMEText(mail_body))
# 메일 전송
smtp.send_message(message)
