- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试通过 smtplib
发送电子邮件,但总是收到属性错误。错误是:
Traceback (most recent call last):
File "C:\Users\intel\Desktop\Python\test.py", line 24, in <module>
server = smtplib.SMTP('smtp.gmail.com', 587)
File "C:\Users\intel\Desktop\Python\smtplib.py", line 195, in __init__
(code, msg) = self.connect(host, port)
File "C:\Users\intel\Desktop\Python\smtplib.py", line 275, in connect
sys.audit("smtplib.connect", self, host, port)
AttributeError: module 'sys' has no attribute 'audit'
I know i am getting error because of this line in my code:
# Step 7 - Create the server connection
server = smtplib.SMTP('smtp.gmail.com', 587)
这是我的代码:
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
import smtplib
# Step 2 - Create message object instance
msg = MIMEMultipart()
# Step 3 - Create message body
message = "Test from Python via AuthSMTP"
# Step 4 - Declare SMTP credentials
password = "password"
username = "andrew.whiteman77@gmail.com"
# Step 5 - Declare message elements
msg['From'] = "your.name@your-domain-name.com"
msg['To'] = "your.name@your-domain-name.com"
msg['Subject'] = "Test from Python via AuthSMTP"
# Step 6 - Add the message body to the object instance
msg.attach(MIMEText(message, 'plain'))
# Step 7 - Create the server connection # here is the line
server = smtplib.SMTP('smtp.gmail.com', 587) # where i am getting error!!!
# Step 8 - Switch the connection over to TLS encryption
server.starttls()
# Step 9 - Authenticate with the server
server.login(username, password)
# Step 10 - Send the message
server.sendmail(msg['From'], msg['To'], msg.as_string())
# Step 11 - Disconnect
server.quit()
# Step 12 -
print("Successfully sent email message to %s:") % (msg['To'])
任何帮助将不胜感激...
最佳答案
sys.audit()是在Python 3.8.0之后添加的,要调用此方法,您应该使用Python +3.8 Docs Audit Events
This table contains all events raised by sys.audit() or PySys_Audit() calls throughout the CPython runtime and the standard library. These calls were added in 3.8.0 or later.
在 smtplib Blob CPython 3.7 Github你可以看到他们没有使用sys.audit()。所以,你的问题是你的Python版本。
关于python - 无属性 : 'audit' found while using smtplib to send emails,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59196222/
我想将 Audit.EntityFramework 与 EntityFramework Core 结合使用,但仅忽略某些实体的审核日志中的插入。我在 Audit.EntityFramework 的 g
我在尝试获取引用未审计实体的审计实体时遇到问题。在我们的应用程序中,某些实体是在不使用 hibernate 的情况下引导的,这些实体是我们的元模型,不需要审计。 工作示例: public class
当我通过以下方式启用创建 session 审核时: audit create session by session; 然后我查询以下内容: select * from dba_priv_audit_o
嘿,这是我第一次使用 thepirat000 Audit.MVC 包,我已经做好了基础并且工作得很好: [Audit(EventTypeName = "InsertOrderAction", Incl
我必须将审计添加到我没有编码的系统中,并且在编程时也没有考虑审计。 然后我遇到了 Audit.Net,这是一个多么棒的框架! 我也在使用 Audit.Mvc 扩展。 无论如何,我想在 HomeCont
这是我得到的错误: npm ERR! code ENOAUDIT npm ERR! audit Your configured registry (https://registry.npmjs.org
我正在试着写一个小的Hello world程序,并用战争来包装它。我正在使用maven并编写一个SpringBoot应用程序来做这件事。。以下是我的Application.Java文件。在构建它时,我
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post一个问题。 4
首先,我对 Oracle 审计跟踪这件事还很陌生。因此,我必须审核特定用户的操作。 我的问题是,当我检查 dba_fga_audit_trail 时,我在 sql_text 列中看到用户运行了删除语句
我正在使用 nightmare 进行测试。运行 npm audit 后,我收到有关 lodash Prototype pollution 的警告。我尝试通过运行 npm audit fix 来修复
我们正在使用 Audit.NET我们的 Asp.Net Core 项目中的库来记录用户操作。最近我们决定使用Hashicorp Vault安全地存储和获取 secret ,包括 数据库凭据 . Vau
最近,由于授权/审计功能的一些奇怪行为,我的一个生产应用程序开始抛出异常。总而言之,我可以向 channel / key 组合授予权限并获得成功响应,但是当我之后立即审核 channel 时,它会显示
有没有人有一个关于如何将审计模型添加到现有项目的工作示例,用于 Audit.Net。 这是一个非常棒的组件,到目前为止,我和我的团队已经使用标准的 JSON 文件,但是,我们希望将当前的解决方案迁移到
在Hibernate中使用@Version和@Audited时,有人可以帮助我解决用例吗? 最佳答案 @Version用于与Hibernate一起实现Optimistic locking,这意味着没有
我正在尝试使用grails audit-logging插件。它似乎可以满足我的需求。 但是,在为自动生成id的域类引用id时遇到问题。 class Person { static auditable
我正在使用Grails 2.2.2,audit-trail插件2.0.3和spring-security-core 1.2.7.3 当我将注释放在类上并使用浏览器(通过Controller / gsp
我正在尝试在基于kubeadm的k8s上启用审核选项。 (v1.11.2) 但是在--audit-policy-file上添加/etc/kubernetes/manifests/kube-apiser
我将@Audited 注释用于我的基本模型。我将其扩展到我的所有实体。但它不起作用。有什么方法可以使用吗 这是我的基本模型 @MappedSuperclass @Getter @Setter @Aud
我正在使用 Audit.NET 和 EntityFramework 扩展,当我仅跟踪 1 个实体时,一切都运行良好。 现在我正在跟踪连接到第一个实体的另一个实体,当我尝试保存它时,审核保存函数会抛出反
当这个方法在 Controller 中执行时: [Route("deleteIncCloseOut")] [HttpDelete] [AuditApi] public bool deleteIncid
我是一名优秀的程序员,十分优秀!