smtplib

SMTP AUTH extension trouble with Python

╄→尐↘猪︶ㄣ 提交于 2019-12-01 09:34:56
I am trying to write a simple Python script to send emails through my company's SMTP server. I am using the following piece of code. #! /usr/local/bin/python import sys,re,os,datetime from smtplib import SMTP #Email function def sendEmail(message): sender="SENDERID@COMPANY.com" receivers=['REVEIVER1@COMPANY.com','RECEIVER2@COMPANY.com'] subject="Daily Report - " + datetime.datetime.now().strftime("%d %b %y") header="""\ From: %s To: %s Subject: %s %s""" % (sender, ", ".join(receivers), subject, message) smtp = SMTP() smtp.set_debuglevel(1) smtp.connect('X.X.X.X') smtp.ehlo() smtp.starttls()

SMTP AUTH extension trouble with Python

大城市里の小女人 提交于 2019-12-01 08:03:09
问题 I am trying to write a simple Python script to send emails through my company's SMTP server. I am using the following piece of code. #! /usr/local/bin/python import sys,re,os,datetime from smtplib import SMTP #Email function def sendEmail(message): sender="SENDERID@COMPANY.com" receivers=['REVEIVER1@COMPANY.com','RECEIVER2@COMPANY.com'] subject="Daily Report - " + datetime.datetime.now().strftime("%d %b %y") header="""\ From: %s To: %s Subject: %s %s""" % (sender, ", ".join(receivers),

How to get server reply after sending a mail using smtplib SMTP.sendmail

穿精又带淫゛_ 提交于 2019-12-01 06:16:06
I have a program to send mail using python smtplib. I have the mail sending part working fine, but I also need to capture the server return message after a mail has been sent. For example postfix returns the following message after a mail has been queueed: reply: '250 2.0.0 Ok: queued as EB83821273B\r\n' reply: retcode (250); Msg: 2.0.0 Ok: queued as EB83821273B data: (250, '2.0.0 Ok: queued as EB83821273B') What I am really interested is the error code (250) and the queue id (EB83821273B). I can print these if I set set_debuglevel(1), but I need to capture this in a variable for further

“No SSL support included in this python” Anaconda-python3-smtplib

烂漫一生 提交于 2019-12-01 05:36:58
I am using Anaconda environment with python 3.7 set up. I am trying to send a simple email via my gmail account using smtplib and I am getting "No SSL support included in this python" I do realize this question has been asked a number times but I can't find concrete suggestions on how to add ssl support in my anaconda/python environment. I installed openssl and pyopenssl, but no luck. Here is my code: import smtplib from email.message import EmailMessage msg = EmailMessage() msg['Subject'] = 'test' msg['From'] = 'xxxx@gmail.com' msg['To'] = 'xxxx@gmail.com' server = smtplib.SMTP('smtp.gmail

How to get server reply after sending a mail using smtplib SMTP.sendmail

爷,独闯天下 提交于 2019-12-01 05:29:06
问题 I have a program to send mail using python smtplib. I have the mail sending part working fine, but I also need to capture the server return message after a mail has been sent. For example postfix returns the following message after a mail has been queueed: reply: '250 2.0.0 Ok: queued as EB83821273B\r\n' reply: retcode (250); Msg: 2.0.0 Ok: queued as EB83821273B data: (250, '2.0.0 Ok: queued as EB83821273B') What I am really interested is the error code (250) and the queue id (EB83821273B). I

Error sending email: raise SMTPAuthenticationError(code, resp)

Deadly 提交于 2019-12-01 04:43:04
问题 Im trying to send emails with smtp module, but Im having an error: File "/usr/lib/python2.7/smtplib.py", in login raise SMTPAuthenticationError(code, resp) smtplib.SMTPAuthenticationError: (534, '5.7.14)... Someone already had this error? Do you know how to fix? The code: def sendNotification(): recepients_list = "emailsmtplibtest@gmail.com" subject = 'Subject' message = "Message" sendemail(recepients_list,subject,message) def sendemail(to_addr_list, subject, message): username =

“No SSL support included in this python” Anaconda-python3-smtplib

前提是你 提交于 2019-12-01 03:43:57
问题 I am using Anaconda environment with python 3.7 set up. I am trying to send a simple email via my gmail account using smtplib and I am getting "No SSL support included in this python" I do realize this question has been asked a number times but I can't find concrete suggestions on how to add ssl support in my anaconda/python environment. I installed openssl and pyopenssl, but no luck. Here is my code: import smtplib from email.message import EmailMessage msg = EmailMessage() msg['Subject'] =

how to add href link in email content when sending email through smtplib

ε祈祈猫儿з 提交于 2019-11-30 13:54:47
问题 I'm sending email through below code: msg = MIMEText(u'<a href="www.google.com">abc</a>') msg['Subject'] = 'subject' msg['From'] = 'xxx' msg['To'] = 'xxx' s = smtplib.SMTP(xxx, 25) s.sendmail(xxx, xxx, msg.as_string()) what I want to receive is abc what I actually received is: <a href="www.google.com">abc</a> 回答1: You should specify 'html' as the subtype - msg = MIMEText(u'<a href="www.google.com">abc</a>','html') Without specifying the subtype separately , the subtype defaults to 'plain'

how to add href link in email content when sending email through smtplib

好久不见. 提交于 2019-11-30 08:57:14
I'm sending email through below code: msg = MIMEText(u'<a href="www.google.com">abc</a>') msg['Subject'] = 'subject' msg['From'] = 'xxx' msg['To'] = 'xxx' s = smtplib.SMTP(xxx, 25) s.sendmail(xxx, xxx, msg.as_string()) what I want to receive is abc what I actually received is: <a href="www.google.com">abc</a> You should specify 'html' as the subtype - msg = MIMEText(u'<a href="www.google.com">abc</a>','html') Without specifying the subtype separately , the subtype defaults to 'plain' (plain-text). From documentations - class email.mime.text.MIMEText(_text[, _subtype[, _charset]]) A subclass of

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

安稳与你 提交于 2019-11-30 02:06:38
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 following code [1] and tested it to be working. import smtplib from email.MIMEMultipart import MIMEMultipart from email.MIMEText import MIMEText from email.MIMEBase import MIMEBase from email import encoders fromaddr = "YOUR EMAIL" toaddr = "EMAIL ADDRESS YOU SEND TO" msg = MIMEMultipart() msg['From'] = fromaddr msg['To'] = toaddr msg['Subject'] =