]>
git.ipfire.org Git - ipfire.org.git/blob - src/web/newsletter.py
10 class SubscribeHandler(base
.BaseHandler
):
13 # Makes sure that we call blacklist for everything
16 @tornado.gen
.coroutine
17 @base.ratelimit(minutes
=15, requests
=5)
19 address
= self
.get_argument("email")
21 # Create an email with us as sender
22 m
= email
.mime
.text
.MIMEText("")
23 m
.add_header("To", "ipfire-announce-join@lists.ipfire.org")
24 m
.add_header("From", address
)
25 m
.add_header("Sender", "no-reply@ipfire.org")
26 m
.add_header("Subject", "Subscribe")
28 logging
.debug("Sending email:\n%s" % m
.as_string())
31 p
= tornado
.process
.Subprocess(["sendmail", "-t"],
32 stdin
=tornado
.process
.Subprocess
.STREAM
)
34 # Pipe the email into sendmail
35 yield tornado
.gen
.Task(p
.stdin
.write
, m
.as_bytes())
37 # Close standard input
40 # Wait until sendmail is done
41 ret
= yield p
.wait_for_exit()
43 logging
.info("%s has subscribed to the newsletter" % address
)
45 self
.render("newsletter/subscribed.html", address
=address
)