本文整理汇总了Python中twisted.mail.smtp.rfc822date函数的典型用法代码示例。如果您正苦于以下问题:Python rfc822date函数的具体用法?Python rfc822date怎么用?Python rfc822date使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了rfc822date函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""
Generate a received header string for a message.
@type helo: 2-L{tuple} of (L{bytes}, L{bytes})
@param helo: The client's identity as sent in the HELO command and its
IP address.
@type origin: L{Address}
@param origin: The origination address of the message.
@type recipients: L{list} of L{User}
@param recipients: The destination addresses for the message.
@rtype: L{bytes}
@return: A received header string.
"""
authStr = heloStr = b""
if self.user:
authStr = b" auth=" + self.user.encode('xtext')
if helo[0]:
heloStr = b" helo=" + helo[0]
fromUser = (b"from " + helo[0] + b" ([" + helo[1] + b"]" +
heloStr + authStr)
by = (b"by " + self.host + b" with " + self.protocolName +
b" (" + networkString(longversion) + b")")
forUser = (b"for <" + b' '.join(map(bytes, recipients)) + b"> " +
smtp.rfc822date())
return (b"Received: " + fromUser + b"\n\t" + by +
b"\n\t" + forUser)
开发者ID:dansgithubuser,项目名称:constructicon,代码行数:30,代码来源:protocols.py
示例2: send_plain_email
def send_plain_email(smtphost, username, password, fromEmail, toEmail, content, headers,
senderDomainName=None, port=25, requireSSL=True):
requireAuth = bool(password)
msg = MIMEText(content)
# Setup the mail headers
for (header, value) in headers.items():
msg[header] = value
headkeys = [k.lower() for k in headers.keys()]
# Add required headers if not present
if "message-id" not in headkeys:
msg["Message-ID"] = messageid()
if "date" not in headkeys:
msg["Date"] = rfc822date()
if "from" not in headkeys and "sender" not in headkeys:
msg["From"] = fromEmail
if "to" not in headkeys and "cc" not in headkeys and "bcc" not in headkeys:
msg["To"] = toEmail
# send message
f = StringIO(msg.as_string())
d = defer.Deferred()
factory = ESMTPSenderFactory(username, password, fromEmail, toEmail, f, d,
requireAuthentication=requireAuth,
requireTransportSecurity=requireSSL)
if senderDomainName is not None:
factory.domain = senderDomainName
connectTCP(smtphost, port, factory)
return d
开发者ID:aldeka,项目名称:leastauthority.com,代码行数:32,代码来源:send_email.py
示例3: receivedHeader
def receivedHeader(self, helo, origin, recipients):
clientHostname, _ = helo
myHostname = self.protocol.transport.getHost().host
headerValue = 'from %s by %s with ESMTP ; %s' % (clientHostname,
myHostname,
smtp.rfc822date())
return 'Received: %s' % Header(headerValue)
开发者ID:carriercomm,项目名称:scripts-16,代码行数:7,代码来源:smtpserver.py
示例4: compose_plain_email
def compose_plain_email(fromEmail, toEmail, content, headers):
msg = MIMEText(content)
# Setup the mail headers
for (header, value) in headers.items():
msg[header] = value
msg.set_charset('utf-8')
headkeys = [k.lower() for k in headers.keys()]
# Add required headers if not present
if "message-id" not in headkeys:
msg["Message-ID"] = messageid()
if "date" not in headkeys:
msg["Date"] = rfc822date()
if "from" not in headkeys and "sender" not in headkeys:
msg["From"] = fromEmail
if "to" not in headkeys and "cc" not in headkeys and "bcc" not in headkeys:
msg["To"] = toEmail
if "reply-to" not in headkeys:
msg["Reply-To"] = SUPPORT_ADDRESS
if "user-agent" not in headkeys:
msg["User-Agent"] = USER_AGENT
return msg.as_string()
开发者ID:BenKoerber,项目名称:leastauthority.com,代码行数:26,代码来源:send_email.py
示例5: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""
Generate a received header string for a message.
@type helo: 2-L{tuple} of (L{bytes}, L{bytes})
@param helo: The client's identity as sent in the HELO command and its
IP address.
@type origin: L{Address}
@param origin: The origination address of the message.
@type recipients: L{list} of L{User}
@param recipients: The destination addresses for the message.
@rtype: L{bytes}
@return: A received header string.
"""
authStr = heloStr = ""
if self.user:
authStr = " auth=%s" % (self.user.encode('xtext'),)
if helo[0]:
heloStr = " helo=%s" % (helo[0],)
from_ = "from %s ([%s]%s%s)" % (helo[0], helo[1], heloStr, authStr)
by = "by %s with %s (%s)" % (
self.host, self.protocolName, longversion
)
for_ = "for <%s>; %s" % (' '.join(map(str, recipients)), smtp.rfc822date())
return "Received: %s\n\t%s\n\t%s" % (from_, by, for_)
开发者ID:alfonsjose,项目名称:international-orders-app,代码行数:28,代码来源:protocols.py
示例6: receivedHeader
def receivedHeader(self, helo, orgin, recipents):
myHostname, clientIP = helo
headerValue = "by %s from %s with ESMTP; %s" % (
myHostname, clientIP, smtp.rfc822date())
retval = "Recieved: %s" % Header(headerValue)
#retval = ""
self.logger.debug("receivedHeader: helo:%s orgin:%s recipents:%s", helo, orgin, [r.dest for r in recipents] )
return retval
开发者ID:bobbynewmark,项目名称:py-smtploadtest,代码行数:8,代码来源:emailsink.py
示例7: receivedHeader
def receivedHeader(self, helo, unused, ignored):
myHostname, self.clientIP = helo
date = smtp.rfc822date()
headerValue = 'by %s from %s with ESMTP ; %s' % (
myHostname, self.clientIP, date)
log.info('Relayed (or sent directly) from: %s', self.clientIP)
header = 'Received: %s' % Header(headerValue)
return header
开发者ID:SteelHouseLabs,项目名称:zenoss-prodbin,代码行数:11,代码来源:zenmail.py
示例8: receivedHeader
def receivedHeader(self, helo, origin, recipients):
authStr = heloStr = ""
if self.user:
authStr = " auth=%s" % (self.user.encode('xtext'),)
if helo[0]:
heloStr = " helo=%s" % (helo[0],)
from_ = "from %s ([%s]%s%s)" % (helo[0], helo[1], heloStr, authStr)
by = "by %s with %s (%s)" % (
self.host, self.protocolName, longversion
)
for_ = "for <%s>; %s" % (' '.join(map(str, recipients)), smtp.rfc822date())
return "Received: %s\n\t%s\n\t%s" % (from_, by, for_)
开发者ID:galaxysd,项目名称:BitTorrent,代码行数:12,代码来源:protocols.py
示例9: receivedHeader
def receivedHeader(self, helo, origin, recipients):
header = conf.smtp_header.format(
sender_ip = helo[1],
sender_host = helo[0],
srv_host = conf.smtp_hostname,
srv_info = conf.srv_version,
sender = conf.smtp_email_delim.join([origin.local, origin.domain]),
id = self.messageid,
rcpt = conf.smtp_email_delim.join([recipients[0].dest.local, recipients[0].dest.domain]),
date = smtp.rfc822date()
)
return 'Received: %s' % Header(header)
开发者ID:inpos,项目名称:serpent,代码行数:12,代码来源:mech_smtp.py
示例10: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""Create the ``Received:`` header for an incoming email.
:type helo: tuple
:param helo: The lines received during SMTP client HELO.
:type origin: :api:`twisted.mail.smtp.Address`
:param origin: The email address of the sender.
:type recipients: list
:param recipients: A list of :api:`twisted.mail.smtp.User` instances.
"""
cameFrom = "%s (%s [%s])" % (helo[0] or origin, helo[0], helo[1])
cameFor = ', '.join(["<{0}>".format(recp.dest) for recp in recipients])
hdr = str("Received: from %s for %s; %s"
% (cameFrom, cameFor, smtp.rfc822date()))
return hdr
开发者ID:mmaker,项目名称:bridgedb,代码行数:15,代码来源:server.py
示例11: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""Create the ``Received:`` header for an incoming email.
:type helo: tuple
:param helo: The lines received during SMTP client HELO.
:type origin: :api:`twisted.mail.smtp.Address`
:param origin: The email address of the sender.
:type recipients: list
:param recipients: A list of :api:`twisted.mail.smtp.User` instances.
"""
helo_ = ' helo={0}'.format(helo[0]) if helo[0] else ''
from_ = 'from %s ([%s]%s)' % (helo[0], helo[1], helo_)
by_ = 'by %s with BridgeDB (%s)' % (smtp.DNSNAME, __version__)
for_ = 'for %s; %s ' % (' '.join(map(str, recipients)), rfc822date())
return str('Received: %s\n\t%s\n\t%s' % (from_, by_, for_))
开发者ID:joelanders,项目名称:bridgedb,代码行数:15,代码来源:server.py
示例12: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""Generates the Received header for a message.
Specified by IMessageDelivery interface.
Args:
helo: The argument to the HELO command and the client's IP address.
origin: The address the message is from.
recipients: A list of the addresses for which this message is bound.
Returns:
The full "Received" header string.
"""
client_hostname, _ = helo
server_hostname = self.protocol.transport.getHost().host
header_value = 'from %s by %s with ESMTP ; %s' % (
client_hostname, server_hostname, smtp.rfc822date())
return 'Received: %s' % (email.Header.Header(header_value),)
开发者ID:dtolnay,项目名称:mailingset,代码行数:18,代码来源:service.py
示例13: writeHeaders
def writeHeaders(self, fromAddress, toAddress, subject=None,
inReplyTo=None, includeMessageID=True,
contentType='text/plain; charset="utf-8"', **kwargs):
"""Write all headers into the response email.
:param str fromAddress: The email address for the ``'From:'`` header.
:param str toAddress: The email address for the ``'To:'`` header.
:type subject: None or str
:param subject: The ``'Subject:'`` header.
:type inReplyTo: None or str
:param inReplyTo: If set, an ``'In-Reply-To:'`` header will be
generated. This should be set to the ``'Message-ID:'`` header from
the client's original request email.
:param bool includeMessageID: If ``True``, generate and include a
``'Message-ID:'`` header for the response.
:param str contentType: The ``'Content-Type:'`` header.
:kwargs: If given, the key will become the name of the header, and the
value will become the Contents of that header.
"""
self.write("From: %s" % fromAddress)
self.write("To: %s" % toAddress)
if includeMessageID:
self.write("Message-ID: %s" % smtp.messageid().encode('utf-8'))
if inReplyTo:
self.write("In-Reply-To: %s" % inReplyTo.encode('utf-8'))
self.write("Content-Type: %s" % contentType.encode('utf-8'))
self.write("Date: %s" % smtp.rfc822date().encode('utf-8'))
if not subject:
subject = '[no subject]'
if not subject.lower().startswith('re'):
subject = "Re: " + subject
self.write("Subject: %s" % subject.encode('utf-8'))
if kwargs:
for headerName, headerValue in kwargs.items():
headerName = headerName.capitalize()
headerName = headerName.replace(' ', '-')
headerName = headerName.replace('_', '-')
header = "%s: %s" % (headerName, headerValue)
self.write(header.encode('utf-8'))
# The first blank line designates that the headers have ended:
self.write(self.delimiter)
开发者ID:liudonghua123,项目名称:bridgedb,代码行数:44,代码来源:autoresponder.py
示例14: addMessage
def addMessage(self, msg, flags=None, date=None):
#print "Add Message: %s :: %s" % (msg, flags)
# passes a file handler here, need to cache fetchBodyFile so I can find the message id.
# list of uids
# uids[sequence_number] = msg_uid
# add new uid
# rpush[msg_uid]
parse = Parser()
email_obj = parse.parse(msg)
fp = StringIO()
g = Generator(fp, mangle_from_=False, maxheaderlen=60)
g.flatten(email_obj)
body = fp.getvalue()
msg_uid = self.conn.incr("%s:mailboxes:%s:uidnext" % (self.user,
self.folder)) - 1;
self.conn.zadd("%s:mailboxes:%s:uidlist"% (self.user, self.folder), msg_uid, msg_uid)
self.seqlist.append((msg_uid, ['\Recent']))
seq_number = len(self.seqlist)
if flags:
self.conn.sadd("%s:mailboxes:%s:mail:%s:flags" % (self.user, self.folder,
msg_uid), *flags)
self.conn.set("%s:mailboxes:%s:mail:%s:date" % (self.user, self.folder,
msg_uid), rfc822date())
self.conn.incr("%s:mailboxes:%s:count" % (self.user, self.folder))
self.conn.set("%s:mailboxes:%s:mail:%s:size" % (self.user, self.folder,
msg_uid), len(body))
self.conn.set("%s:mailboxes:%s:mail:%s:body" % (self.user, self.folder,
msg_uid), body)
self.conn.sadd("%s:mailboxes:%s:mail:%s:headers" % (self.user, self.folder,
msg_uid), *(email_obj.keys()))
#print email_obj.keys()
for header in email_obj.keys():
self.conn.set("%s:mailboxes:%s:mail:%s:header:%s" % (self.user,
self.folder, msg_uid, header.lower()), email_obj[header])
#print header, msg_uid, self.folder, self.user
self.conn.incr("%s:mailboxes:%s:recent" % (self.user, self.folder))
self.recent_count += 1
self.conn.publish("%s:mailboxes:%s:channel" % (self.user, self.folder),
"count %d" % (msg_uid))
return defer.succeed(seq_number)
开发者ID:via,项目名称:cloudmail,代码行数:44,代码来源:cloudmail.py
示例15: send
def send(self, response):
message = response['reply']
response['To'] = response['target']
response['Date'] = smtp.rfc822date()
if 'Subject' not in response:
response['Subject'] = 'Message from %s' % ibid.config['botname']
response['Content-Type'] = 'text/plain; charset=utf-8'
del response['target']
del response['source']
del response['reply']
body = ''
for header, value in response.items():
body += '%s: %s\n' % (header, value)
body += '\n'
body += message
port = ':' in self.relayhost and int(self.relayhost.split(':')[1]) or 25
smtp.sendmail(self.relayhost.split(':')[0], self.address, response['To'], body.encode('utf-8'), port=port)
self.log.debug(u"Sent email to %s: %s", response['To'], response['Subject'])
开发者ID:B-Rich,项目名称:ibid-1,代码行数:21,代码来源:smtp.py
示例16: receivedHeader
def receivedHeader(self, helo, origin, recipients):
"""
Generate the 'Received:' header for a message.
:param helo: The argument to the HELO command and the client's IP
address.
:type helo: (str, str)
:param origin: The address the message is from.
:type origin: twisted.mail.smtp.Address
:param recipients: A list of the addresses for which this message is
bound.
:type: list of twisted.mail.smtp.User
@return: The full "Received" header string.
:type: str
"""
myHostname, clientIP = helo
headerValue = "by bitmask.local from %s with ESMTP ; %s" % (
clientIP, smtp.rfc822date())
# email.Header.Header used for automatic wrapping of long lines
return "Received: %s" % Header(s=headerValue, header_name='Received')
开发者ID:leapcode,项目名称:leap_mail,代码行数:21,代码来源:gateway.py
示例17: requestAvatarId
def requestAvatarId(self, credentials):
api = twitter.Api(
username=credentials.username,
password=credentials.password,
input_encoding=None,
request_headers={"X-Twitter-Client": "twIMAPd", "X-Twitter-Client-Version": ".5"},
)
self.cache.set("api", api)
self.cache.set("username", credentials.username)
try:
user = api.GetDirectMessages()
try:
file = open("/tmp/%s_twimap.db" % credentials.username)
except IOError:
createDB = True
else:
createDB = False
conn = sqlite.connect("/tmp/%s_twimap.db" % credentials.username)
cur = conn.cursor()
if createDB:
sql = "create table log (key text, value text)"
cur.execute(sql)
# sql = "create table messages (id integer primary key, folder text, headers text, seen integer default 0, deleted integer default 0, message text)"
sql = "create table messages (msgid integer primary key, id integer, folder text, headers text, seen integer default 0, deleted integer default 0, message text)"
cur.execute(sql)
sql = "create unique index messagelist on messages (id, folder)"
cur.execute(sql)
sql = "create unique index folders on log (key, value)"
cur.execute(sql)
cur.execute('delete from log where (key = "lastcheck")')
sql = 'insert into log (key, value) values ("lastcheck", "%s")' % rfc822date(time.localtime())
print "SQL :: %s" % sql
cur.execute(sql)
conn.commit()
self.cache.set("conn", conn)
return defer.succeed(credentials.username)
except HTTPError:
return defer.fail(credError.UnauthorizedLogin("Bad password - fool"))
开发者ID:nborwankar,项目名称:twimapd,代码行数:40,代码来源:twittermail.py
示例18: send_plain_email
def send_plain_email(fromEmail, toEmail, content, headers):
if REQUIRE_AUTH:
password = FilePath(SMTP_PASSWORD_PATH).getContent().strip()
else:
password = None
msg = MIMEText(content)
# Setup the mail headers
for (header, value) in headers.items():
msg[header] = value
headkeys = [k.lower() for k in headers.keys()]
# Add required headers if not present
if "message-id" not in headkeys:
msg["Message-ID"] = messageid()
if "date" not in headkeys:
msg["Date"] = rfc822date()
if "from" not in headkeys and "sender" not in headkeys:
msg["From"] = fromEmail
if "to" not in headkeys and "cc" not in headkeys and "bcc" not in headkeys:
msg["To"] = toEmail
if "reply-to" not in headkeys:
msg["Reply-To"] = SUPPORT_ADDRESS
if "user-agent" not in headkeys:
msg["User-Agent"] = USER_AGENT
if "content-type" not in headkeys:
msg["Content-Type"] = CONTENT_TYPE
# send message
f = StringIO(msg.as_string())
d = defer.Deferred()
factory = ESMTPSenderFactory(SMTP_USERNAME, password, fromEmail, toEmail, f, d,
requireAuthentication=REQUIRE_AUTH,
requireTransportSecurity=REQUIRE_TRANSPORT_SECURITY)
factory.domain = SENDER_DOMAIN
connectTCP(SMTP_HOST, SMTP_PORT, factory)
return d
开发者ID:ArtRichards,项目名称:leastauthority.com,代码行数:40,代码来源:send_email.py
示例19: headers
def headers(self):
local = time.localtime(int(self.macros['TIMET']))
user = pwd.getpwuid(os.getuid())[0]
host = socket.getfqdn()
ret = {
'Subject': self.subject(),
'To': self.macros['CONTACTEMAIL'],
'From': "%[email protected]%s" % (user, host),
'Date': smtp.rfc822date(local),
'X-Nagios-Notification-Type': self.macros['NOTIFICATIONTYPE'],
'X-Nagios-Host-Name': self.macros['HOSTNAME'],
'X-Nagios-Host-State': self.macros['HOSTSTATE'],
'X-Nagios-Host-Groups': self.macros['HOSTGROUPNAMES']
}
if self.type == "service":
ret['X-Nagios-Service-Description'] = self.macros['SERVICEDESC']
ret['X-Nagios-Service-State'] = self.macros['SERVICESTATE']
ret['X-Nagios-Service-Groups'] = self.macros['SERVICEGROUPNAMES']
return ret
开发者ID:jordane,项目名称:nagcat,代码行数:22,代码来源:notify_smtp.py
示例20: generateEmail
def generateEmail(self, inviteState, calendar, orgEmail, orgCN,
attendees, fromAddress, replyToAddress, toAddress,
language='en'):
"""
Generate MIME text containing an iMIP invitation, cancellation, update
or reply.
@param inviteState: 'new', 'update', or 'reply'.
@type inviteState: C{str}
@param calendar: the iCalendar component to attach to the email.
@type calendar: L{twistedcaldav.ical.Component}
@param orgEmail: The email for the organizer, in C{[email protected]}
format, or C{None} if the organizer has no email address.
@type orgEmail: C{str} or C{NoneType}
@param orgCN: Common name / display name for the organizer.
@type orgCN: C{unicode}
@param attendees: A C{list} of 2-C{tuple}s of (common name, email
address) similar to (orgEmail, orgCN).
@param fromAddress: the address to use in the C{From:} header of the
email.
@type fromAddress: C{str}
@param replyToAddress: the address to use in the C{Reply-To} header.
@type replyToAddress: C{str}
@param toAddress: the address to use in the C{To} header.
@type toAddress: C{str}
@param language: a 2-letter language code describing the target
language that the email should be generated in.
@type language: C{str}
@return: a 2-tuple of C{str}s: (message ID, message text). The message
ID is the value of the C{Message-ID} header, and the message text is
the full MIME message, ready for transport over SMTP.
"""
details = self.getEventDetails(calendar, language=language)
canceled = (calendar.propertyValue("METHOD") == "CANCEL")
subjectFormat, labels = localizedLabels(language, canceled, inviteState)
details.update(labels)
details['subject'] = subjectFormat % {'summary' : details['summary']}
plainText = self.renderPlainText(details, (orgCN, orgEmail),
attendees, canceled)
htmlText = self.renderHTML(details, (orgCN, orgEmail),
attendees, canceled)
msg = MIMEMultipart()
msg["From"] = fromAddress
msg["Subject"] = details['subject']
msg["Reply-To"] = replyToAddress
msg["To"] = toAddress
msg["Date"] = rfc822date()
msgId = messageid()
msg["Message-ID"] = msgId
msgAlt = MIMEMultipart("alternative")
msg.attach(msgAlt)
# plain version
msgPlain = MIMEText(plainText, "plain", "UTF-8")
msgAlt.attach(msgPlain)
# html version
msgHtmlRelated = MIMEMultipart("related", type="text/html")
msgAlt.attach(msgHtmlRelated)
msgHtml = MIMEText(htmlText, "html", "UTF-8")
msgHtmlRelated.attach(msgHtml)
calendarText = str(calendar)
# the icalendar attachment
self.log.debug("Mail gateway sending calendar body: %s"
% (calendarText,))
msgIcal = MIMEText(calendarText, "calendar", "UTF-8")
method = calendar.propertyValue("METHOD").lower()
msgIcal.set_param("method", method)
msgIcal.add_header("Content-ID", "<invitation.ics>")
msgIcal.add_header("Content-Disposition",
"inline;filename=invitation.ics")
msg.attach(msgIcal)
return msgId, msg.as_string()
开发者ID:svn2github,项目名称:calendarserver-raw,代码行数:100,代码来源:outbound.py
注:本文中的twisted.mail.smtp.rfc822date函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论