|
13 | 13 | limitations under the License.""" |
14 | 14 |
|
15 | 15 | import os |
16 | | -from smtplib import SMTP |
17 | | -from socket import gethostname |
18 | | -from email.mime.multipart import MIMEMultipart |
19 | | -from email.mime.text import MIMEText |
20 | | -from email.mime.image import MIMEImage |
21 | | -from six.moves.http_client import HTTPConnection |
22 | | -from six.moves.urllib.parse import urlsplit |
23 | | -from time import ctime, strftime |
24 | | -from traceback import format_exc |
25 | 16 | from graphite.user_util import getProfile |
26 | 17 | from graphite.logger import log |
27 | 18 | from graphite.account.models import MyGraph |
@@ -90,35 +81,3 @@ def mygraph(request): |
90 | 81 |
|
91 | 82 | else: |
92 | 83 | return HttpResponse("Invalid operation '%s'" % action) |
93 | | - |
94 | | - |
95 | | -def send_email(request): |
96 | | - try: |
97 | | - recipients = request.GET['to'].split(',') |
98 | | - url = request.GET['url'] |
99 | | - proto, server, path, query, frag = urlsplit(url) |
100 | | - if query: path += '?' + query |
101 | | - conn = HTTPConnection(server) |
102 | | - conn.request('GET',path) |
103 | | - try: # Python 2.7+, use buffering of HTTP responses |
104 | | - resp = conn.getresponse(buffering=True) |
105 | | - except TypeError: # Python 2.6 and older |
106 | | - resp = conn.getresponse() |
107 | | - assert resp.status == 200, "Failed HTTP response %s %s" % (resp.status, resp.reason) |
108 | | - rawData = resp.read() |
109 | | - conn.close() |
110 | | - message = MIMEMultipart() |
111 | | - message['Subject'] = "Graphite Image" |
112 | | - message['To'] = ', '.join(recipients) |
113 | | - message['From'] = 'composer@%s' % gethostname() |
114 | | - text = MIMEText( "Image generated by the following graphite URL at %s\r\n\r\n%s" % (ctime(),url) ) |
115 | | - image = MIMEImage( rawData ) |
116 | | - image.add_header('Content-Disposition', 'attachment', filename="composer_" + strftime("%b%d_%I%M%p.png")) |
117 | | - message.attach(text) |
118 | | - message.attach(image) |
119 | | - s = SMTP(settings.SMTP_SERVER) |
120 | | - s.sendmail('composer@%s' % gethostname(),recipients,message.as_string()) |
121 | | - s.quit() |
122 | | - return HttpResponse( "OK" ) |
123 | | - except Exception: |
124 | | - return HttpResponse(format_exc()) |
0 commit comments