python发送电子邮件-未定义名称“服务器”

时间:2021-07-30 09:23:03

标签: python

未定义名称“服务器”

示例:

import smtplib

import  pandas as p
import smtplib as s
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText



try:#server log in
    server.sm.SMTP("smtpout.secureserver.net", 587)
    server.starttlss()
    server.login("log name" "pass")

    from_="info"
    to_ = list_of_Emails
    message=MIMEMultipart("alternative")
    message[subject]="hi world first check"
    message["from"] = "name"


    html='''
    <html>
    <head>
    
    </head>
    <body>
    <h1>hi eyal first check</h1>
    <h2>HI EYAL FIRST CHECK</h2>
    <P>HELLO WORLD</P>
    <button style=""padding:20px;background;Green;color:white; >EYAL SHMUEL</button>
    
    </body>
    </html>
    
    
    '''

    text=MIMEText(html,"html")

    server.sendmail(from_, to_, message.as_string())
    print("message send to the emails")


except Exception as e:
    print(e)

我得到错误。名称服务器未定义

0 个答案:

没有答案