Source

pypi / webui / messages.py

Full commit
import smtplib

# email sent to user indicating how they should complete their registration
rego_message = '''Subject: Complete your Cheese Shop registration
From: %(admin)s
To: %(email)s

To complete your registration of the user "%(name)s" with the python module
index, please visit the following URL:

  %(url)s?:action=user&otk=%(otk)s

'''

# password change request email
password_change_message = '''Subject: Cheese Shop password change request
From: %(admin)s
To: %(email)s

Someone, perhaps you, has requested that the password be changed for your
username, "%(name)s". If you wish to proceed with the change, please follow
the link below:

  %(url)s?:action=password_reset&email=%(email)s

You should then receive another email with the new password.

'''

# password reset email - indicates what the password is now
password_message = '''Subject: Cheese Shop password has been reset
From: %(admin)s
To: %(email)s

Your login is: %(name)s
Your password is now: %(password)s
'''

unauth_message = '''
<p>If you are a new user, <a href="%(url_path)s?:action=register_form">please
register</a>.</p>
<p>If you have forgotten your password, you can have it
<a href="%(url_path)s?:action=forgotten_password_form">reset for you</a>.</p>
'''

comment_message = '''Subject: New comment on %(package)s
From: PyPI operators <%(admin)s>
To: %(email)s
Reply-To: %(replyto)s

[REPLIES TO THIS MESSAGE WILL NOT GO TO THE COMMENTER]
%(author)s has made the following comment on your package.

%(comment)s

You can read all comments on %(url)s.
'''

def comment_email(store, package, version, author, comment, add_recipients):
    emails = set()
    recipients = [r['user_name'] for r in store.get_package_roles(package)] + add_recipients
    for r in recipients:
        email = store.get_user(r)['email']
        if email:
            emails.add(email)
    info = {
        'package': package,
        'admin': store.config.adminemail,
        'replyto': store.config.replyto,
        'author': author,
        'email': ','.join(emails),
        'comment': comment,
        'url': '%s/%s/%s' % (store.config.url, package, version),
        }
    smtp = smtplib.SMTP(store.config.mailhost)
    smtp.sendmail(store.config.adminemail, list(emails), comment_message % info)