Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F68848201
mail.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sat, Jun 29, 04:38
Size
704 B
Mime Type
text/x-python
Expires
Mon, Jul 1, 04:38 (2 d)
Engine
blob
Format
Raw Data
Handle
18484561
Attached To
R3600 invenio-infoscience
mail.py
View Options
import
smtplib
def
send_email
(
fromaddr
,
toaddr
,
body
,
attempt
=
0
):
if
toaddr
!=
""
:
if
attempt
>
2
:
raise
functionError
(
'error sending email to
%s
: SMTP error; gave up after 3 attempts'
%
toaddr
)
try
:
server
=
smtplib
.
SMTP
(
'localhost'
)
server
.
sendmail
(
fromaddr
,
toaddr
,
body
)
server
.
quit
()
except
:
time
.
sleep
(
10
)
send_email
(
fromaddr
,
toaddr
,
body
,
attempt
+
1
)
return
def
forge_email
(
fromaddr
,
toaddr
,
bcc
,
subject
,
content
):
body
=
'From:
%s
\n
To:
%s
\n
bcc:
%s
\n
Content-Type: text/plain; charset=utf-8
\n
Subject:
%s
\n
%s
'
%
(
fromaddr
,
toaddr
,
bcc
,
subject
,
content
)
return
body
Event Timeline
Log In to Comment