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

1300 questions
0
votes
0 answers

Sending e-mail to distribution list using python smtp

I'm trying to send an e-mail to a distribution list using smtplib. The following is my code: to = ['distlist@company.com'] username = 'user' password = 'pw' smtpserver = smtplib.SMTP("server", 587) smtpserver.ehlo() …
EgoKilla
  • 131
  • 12
0
votes
0 answers

passing variables to HTML email in Python

I am sending an email in Python and am trying to pass a variable in the HTML. I see that this can be done with "formatstring".format, but I am unable to do it successfully. Here's a short(er) version of what I have: email_to = [] email_apiendpoint =…
EricY
  • 376
  • 1
  • 3
  • 19
0
votes
2 answers

How to send email while keeping the To: list blank and only Bcc: list populated using sendmail function of smtplib in python

I am new to Python. I have a case where I need to send email where the Bcc: list must be populated and To: list must be blank in order to hide the recipients identity. I gave msg['TO']as '', None, [''], []. None of these worked. I Googled, but…
Krishnachandra Sharma
  • 1,332
  • 2
  • 20
  • 42
0
votes
1 answer

Python Email TypeError: expected string or buffer

In a very simple example of sending an email: import smtplib from email.mime.text import MIMEText message = MIMEText("test message") s = smtplib.SMTP('localhost') s.sendmail("example@example.com", ["example@example.com"], message) I get the…
Zags
  • 37,389
  • 14
  • 105
  • 140
0
votes
0 answers

SSL certificates work with Python 2.6.6's smtplib but not with Python 2.7.9

The code is: import smtplib SERVER = XXX PORT = 587 USERNAME = YYY PASSWORD = ZZZZ SENDER = 'foo@domain.com' RECEIVERS = ['bar@anotherdomain.com', ] CERTFILE = "/path/to/certfile.crt" KEYFILE = "/path/to/certfile.key" client =…
marcelor
  • 92
  • 3
0
votes
1 answer

Correct way to handle UTF-8 for outgoing email

Anyone could explain what's the correct way to send this email on UTF-8 form? Destination received as human unreadable code. Edit1: added more detail on the code which shows where uploaded_file variable come from. Edit2: Added last section of the…
Thomas G. Lau
  • 226
  • 3
  • 14
0
votes
1 answer

smtplib.SMTPResponseException: 535 Incorrect authentication data Apache, python, smtplib module

I'm trying to send an email via SMTP server at my university. I wrote some python code. The code itself works fine, but I think there's a problem with SMTP server. I think I should contact the administrator but what should I tell him? Is it really a…
yawn
  • 5
  • 4
0
votes
1 answer

sending email from python 3.4 script, WITHOUT enabling 'less secure apps' in gmail

I would like to send mail using a python 3.4 script, from my gmail address. I use the following code: import smtplib def sendmail(): sender='myemail@gmail.com' receiver=['someone@gmail.com'] message='text here' try: …
Wanek T
  • 25
  • 2
  • 6
0
votes
1 answer

SMTP Server Login Failure for smtplib

I've written a function to text a verizon cell phone from a gmail account, and I'm having issues logging in to the smtp server. The function looks like: def _text(fromwhom,number,text): """ A private function which sends an SMS message to a…
astromax
  • 6,001
  • 10
  • 36
  • 47
0
votes
1 answer

How can I fetch the SMTP headers after sending email?

I'm able to send emails using smtplib with ease. What I'm struggling with is reading the actual headers that were sent one. Specifically, I'm looking to read the Message-ID and References. I thought at first that sendmail() would return them, but it…
onetwothree
  • 672
  • 1
  • 10
  • 20
0
votes
1 answer

Send mail with smtplib using proxy

I have a very basic piece of Python code: import smtplib server = smtplib.SMTP(host, port) problems = server.sendmail(from_addr, to_addr, message) Is there solution to run it behind an HTTP proxy? I am using Python 3.4.1 on Linux with…
jesse
  • 13
  • 1
  • 6
0
votes
4 answers

smtplib of python not working

Trying to connect to smpt server of gmail but it is giving network unreachable import smtplib s=smtplib.SMTP('smtp.gmail.com',587) Neither this is working import smtplib s=smtplib.SMTP_SSL('smtp.gmail.com',587) It is giving following…
Vipul
  • 566
  • 5
  • 29
0
votes
1 answer

smtplib sometimes can't send a string variable from sqlite concatenated to a string literal

I am trying to send a message in Python with smtplib. I have a sendEmail(message) function: def sendEmail(message) server = smtplib.SMTP_SSL('mailserver.example.com', 465) server.ehlo() server.login("username", "password") print…
0
votes
1 answer

Python smtplib sending mail using docmd

I currently have an smtplib client using sendmail. I need to trap the message id given to the sent message by the receiving server - and from what I've read here I need to use smtplib's docmd command. What I've worked out so far is fairly…
Steve Hall
  • 469
  • 1
  • 5
  • 23
0
votes
1 answer

Python preppy producing offensive leading blank line

I'm trying to use preppy to template some email messages, but it inserts a leading blank line which causes SMTP to treat everything as message body in stead of headers. In a standalone test I'm using the following python code: import preppy premsg…
The Tahaan
  • 6,915
  • 4
  • 34
  • 54