1200字范文,内容丰富有趣,写作的好帮手!
1200字范文 > smtplib python_伪造邮件发件人系列:一 python之smtplib库

smtplib python_伪造邮件发件人系列:一 python之smtplib库

时间:2021-06-13 14:12:40

相关推荐

smtplib python_伪造邮件发件人系列:一 python之smtplib库

这两日用到了python的发送邮件功能,恰好又想起来wordpress发送给我的邮件都是形如wordpress@leniy.info

的虚拟地址,于是我就上网查找了下伪造邮件发件人的方案。网上这些资料非常多,以下是个人感兴趣的部分内容的汇总。

声明:本系列文章均为博主个人学习中收集到的网络资源的汇总笔记,不保证其时效性安全性,请勿用于非正当途径。

原文标题:Python – Sending Email using SMTP

原文地址:/python/python_sending_email.htm

原文作者:tutorialspoint

相关内容:

Simple Mail Transfer Protocol (SMTP) is a protocol which handles sending e-mail and routing e-mail between mail servers.

Python provides smtplib module which defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.

Here is a simple syntax to create one SMTP object which can later be used to send an email:

import smtplib

smtpObj = smtplib.SMTP( [host [, port [, local_hostname]]] )

Here is the detail of the parameters:host: This is the host running your SMTP server. You can specifiy IP address of the host or a domain name like . This is optional argument.

port: If you are providing host argument then you need to specifiy a port where SMTP server is listening. Usually this port would be 25.

local_hostname: If your SMTP server is running on your local machine then you can specify just localhost as of this option.The sender – A string with the address of the sender.

The receivers – A list of strings, one for each recipient.

The message – A message as a string formatted as specified in the various RFCs.

#!/usr/bin/python

import smtplib

sender = 'from@'

receivers = ['to@']

message = """From: From Person

To: To Person

Subject: SMTP e-mail test

This is a test e-mail message.

"""

try:

smtpObj = smtplib.SMTP('localhost')

smtpObj.sendmail(sender, receivers, message)

print "Successfully sent email"

except SMTPException:

print "Error: unable to send email"

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。