Questions tagged [smtplib]

`smtplib` is a Python module that defines an SMTP client session object. It can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.

smtplib is a Python module that defines an SMTP client session object. It can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon. For details of SMTP and ESMTP operation, consult RFC 821 (Simple Mail Transfer Protocol) and RFC 1869 (SMTP Service Extensions).

Reference: http://docs.python.org/library/smtplib.html

1059 questions
236
votes
13 answers

How to send email to multiple recipients using python smtplib?

After much searching I couldn't find out how to use smtplib.sendmail to send to multiple recipients. The problem was every time the mail would be sent the mail headers would appear to contain multiple addresses, but in fact only the first recipient…
user1148320
  • 2,361
  • 2
  • 12
  • 3
187
votes
11 answers

How to send an email with Python?

This code works and sends me an email just fine: import smtplib #SERVER = "localhost" FROM = 'monty@python.com' TO = ["jon@mycompany.com"] # must be a list SUBJECT = "Hello!" TEXT = "This message was sent with Python's smtplib." # Prepare…
cloud311
  • 2,381
  • 4
  • 18
  • 20
77
votes
8 answers

Python: "subject" not shown when sending email using smtplib module

I am successfully able to send email using the smtplib module. But when the emial is sent, it does not include the subject in the email sent. import smtplib SERVER = FROM = TO = [] SUBJECT = "Hello!" message…
nsh
  • 1,139
  • 4
  • 11
  • 14
76
votes
3 answers

SMTPAuthenticationError when sending mail using gmail and python

when i try to send mail using gmail and python error occurred this type of question are already in this site but doesn't help to me gmail_user = "me@gmail.com" gmail_pwd = "password" TO = 'friend@gmail.com' SUBJECT = "Testing sending using…
mans
  • 933
  • 1
  • 7
  • 6
43
votes
7 answers

Sendmail Errno[61] Connection Refused

I've been trying to get my application to mail some outputted text to an email. For simplification I have isolated the script : import smtplib import sys import os SERVER = "localhost" FROM = os.getlogin() TO = [raw_input("To : ")] SUBJECT =…
Tehnix
  • 1,882
  • 2
  • 15
  • 22
41
votes
6 answers

SMTP AUTH extension not supported by server

Using python I want to send email from my app but it shows the error SMTP AUTH extension not supported by server Code for the program, import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText fromaddr =…
KKD
  • 539
  • 1
  • 4
  • 13
38
votes
5 answers

Setting different reply-to message in Python email/smtplib

I am using Python email and smtplib to send an email from Python. I am doing this via the Gmail SMTP server using my Gmail credentials. This works fine, however I would like to specify a Reply-to email address different from the from address, so…
eli
  • 3,206
  • 7
  • 22
  • 28
29
votes
5 answers

How to get line breaks in e-mail sent using Python's smtplib?

I have written a script that writes a message to a text file and also sends it as an email. Everything goes well, except the email finally appears to be all in one line. I add line breaks by \n and it works for the text file but not for the email.…
f.ashouri
  • 4,839
  • 12
  • 38
  • 52
27
votes
3 answers

Mails not being sent to people in CC

I have the following script for sending mails using python import smtplib from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText import os FROMADDR = "myaddr@server.com" PASSWORD = 'foo' TOADDR =…
Pulimon
  • 1,706
  • 3
  • 28
  • 44
27
votes
1 answer

How to fix ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056)?

I am trying to send an email with python, but it keeps saying ssl.SSLError: [SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:1056). Here is my code: server = smtplib.SMTP_SSL('smtp.mail.com', 587) server.login("something0@mail.com",…
TheRealTengri
  • 645
  • 1
  • 4
  • 14
27
votes
1 answer

MIMEMultipart, MIMEText, MIMEBase, and payloads for sending email with file attachment in Python

Without much prior knowledge of MIME, I tried to learned how to write a Python script to send an email with a file attachment. After cross-referencing Python documentation, Stack Overflow questions, and general web searching, I settled with the…
Ken Lin
  • 725
  • 1
  • 5
  • 17
25
votes
9 answers

smtplib and gmail - python script problems

Here's my script: #!/usr/bin/python import smtplib msg = 'Hello world.' server = smtplib.SMTP('smtp.gmail.com',587) #port 465 or…
spencewah
  • 2,037
  • 3
  • 20
  • 28
23
votes
6 answers

How do I send attachments using SMTP?

I want to write a program that sends email using Python's smtplib. I searched through the document and the RFCs, but couldn't find anything related to attachments. Thus, I'm sure there's some higher-level concept I'm missing out on. Can someone…
Jason Baker
  • 171,942
  • 122
  • 354
  • 501
22
votes
10 answers

Failing to send email with the Python example

I've been trying (and failing) to figure out how to send email via Python. Trying the example from here: http://docs.python.org/library/smtplib.html#smtplib.SMTP but added the line server = smtplib.SMTP_SSL('smtp.gmail.com', 465) after I got a…
Chatter
  • 241
  • 1
  • 3
  • 4
18
votes
3 answers

Issue with smtplib sending mail with unicode characters in Python 3.1

Hello i' ve this problem with unicode emails, when i try to send words in spanish like: "Añadir" or others the system collapse, i've try what says on this link: Python 3 smtplib send with unicode characters and doesn't work. This is the code of my…
hidura
  • 641
  • 2
  • 11
  • 33
1
2 3
70 71