connection=mysql.connector.connect(host='localhost',database='sap',user='root',password='sap')
sql = """SELECT email FROM users WHERE username = '%s'""" % (username)
cursor = connection.cursor()
cursor.execute(sql)
records = cursor.fetchall()
time.sleep(2)
no_of_rows = cursor.rowcount
print("number of rows =",records[0])
xx = records[0]
现在我需要在另一个函数中使用值xx,它是来自数据库的电子邮件地址,以便使用python脚本发送电子邮件:
server.sendmail(sender_email, emailstr, message.as_string())
我得到的错误是:
smtplib.SMTPRecipientsRefused: {"('hasan.mudhafar@gmail.com',)": (553, b"5.1.2 The recipient address <('hasan.mudhafar@gmail.com',)> is not a valid\n5.1.2 RFC-5321 address. v6sm5472017wru.6 - gsmtp")}
该代码不接受电子邮件地址,因为它包含以下字符:当从db:('')接收电子邮件时,如何删除它们或如何仅获取不包含这些字符的电子邮件
目前没有回答
相关问题 更多 >
编程相关推荐