Index: django/conf/global_settings.py =================================================================== --- django/conf/global_settings.py (revision 4908) +++ django/conf/global_settings.py (working copy) @@ -108,6 +108,7 @@ # Optional SMTP authentication information for EMAIL_HOST. EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' +EMAIL_TLS = False # encrypt the connection using TLS/SSL? # List of strings representing installed apps. INSTALLED_APPS = () Index: django/core/mail.py =================================================================== --- django/core/mail.py (revision 4908) +++ django/core/mail.py (working copy) @@ -17,14 +17,14 @@ val = Header(val, settings.DEFAULT_CHARSET) MIMEText.__setitem__(self, name, val) -def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): +def send_mail(subject, message, from_email, recipient_list, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD, tls=getattr(settings, 'EMAIL_TLS', False)): """ Easy wrapper for sending a single message to a recipient list. All members of the recipient list will see the other recipients in the 'To' field. """ - return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password) + return send_mass_mail([[subject, message, from_email, recipient_list]], fail_silently, auth_user, auth_password, tls) -def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD): +def send_mass_mail(datatuple, fail_silently=False, auth_user=settings.EMAIL_HOST_USER, auth_password=settings.EMAIL_HOST_PASSWORD, tls=getattr(settings, 'EMAIL_TLS', False)): """ Given a datatuple of (subject, message, from_email, recipient_list), sends each message to each recipient list. Returns the number of e-mails sent. @@ -34,6 +34,9 @@ """ try: server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT) + if tls: + server.starttls() + server.ehlo() if auth_user and auth_password: server.login(auth_user, auth_password) except: