파이썬으로 네이버웍스 메일 보내기

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText


def sendMail(from_, pw_, to_, title_, content_):
    message = MIMEMultipart()
    message["Subject"] = title_
    message["From"] = from_
    message["To"] = to_

    mimetext = MIMEText(content_, "html")
    message.attach(mimetext)

    server = smtplib.SMTP("smtp.worksmobile.com", 587)  # 네이버웍스 메일 서버, SMTP 포트
    server.ehlo()
    server.starttls()
    server.login(from_, pw_)
    server.sendmail(message["From"], to_, message.as_string())
    server.quit()


if __name__ == "__main__":
    from_ = ""  # 보내는 사람 메일
    pw_ = ""  # 외부 접근용 비밀번호
    to_ = ""  # 받는 사람 메일
    name_ = ""  # 이름
    title_ = ""  # 메일 제목
    content_ = ""  # 메일 본문

    sendMail(from_, pw_, to_, title_, content_)

네이버 웍스 외부 접근

외부에서 이메일을 보내려면 외부 접근용 비밀번호가 필요하다. 학교 계정은 네이버웍스로 연동되어 있기 때문에 네이버 웍스에서 외부 비밀번호를 생성하면 된다.

  1. 환경 설정 -> 메일 -> 고급 설정 -> IMAP/SMTP -> 외부 앱 비밀번호 생성하기 -> 새 비밀번호 생성 -> 복사

image

image

image

image

image

image

image