This file is indexed.

/usr/lib/python2.7/dist-packages/sagenb/notebook/smtpsend.py is in python-sagenb 1.0.1+ds1-2.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# -*- coding: utf-8 -*
"""nodoctest
"""

#############################################################################
#       Copyright (C) 2007 William Stein <wstein@gmail.com>
#  Distributed under the terms of the GNU General Public License (GPL)
#  The full text of the GPL is available at:
#                  http://www.gnu.org/licenses/
#############################################################################
from __future__ import print_function  # must be here !

"""
Sending mail using Twisted

AUTHOR:
    -- Bobby Moretti
"""


from twisted.mail import smtp, relaymanager
from twisted.internet import reactor, defer
from email.MIMEBase import MIMEBase
from email.MIMEMultipart import MIMEMultipart
from email import Encoders
import sys
import mimetypes
import os


def buildMessage(fromaddr, toaddr, subject, body):
    message = MIMEMultipart()
    message['From'] = fromaddr
    message['To'] = toaddr
    message['Subject'] = subject
    textPart = MIMEBase('text', 'plain')
    textPart.set_payload(body)
    message.attach(textPart)
    return message

def sendComplete(result):
    print("Message sent.")

def handleError(error):
    print("Error {}".format(error.getErrorMessage()), file=sys.stderr)

def send_mail(fromaddr, toaddr, subject, body, on_success=sendComplete, on_failure=handleError):
    try:
        recpt_domain = toaddr.split('@')[1].encode("ascii")
    except (ValueError, IndexError, UnicodeDecodeError):
        raise ValueError("mal-formed destination address")
    message = buildMessage(fromaddr, toaddr, subject, body)
    messageData = message.as_string(unixfrom=False)

    def on_found_record(mx_rec):
        smtp_server = str(mx_rec.name)
        sending = smtp.sendmail(smtp_server, fromaddr, [toaddr], messageData)
        sending.addCallback(on_success).addErrback(on_failure)
        
    relaymanager.MXCalculator().getMX(recpt_domain).addCallback(on_found_record)