Python Forum
smtlib send email without logging in
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
smtlib send email without logging in
#1
import smtplib

from email.mime.text import MIMEText

with open(textfile) as fp:

    msg = MIMEText(fp.read())

msg['Subject'] = 'something'
msg['From'] = me
msg['To'] = you

s = smtplib.SMTP('localhost')
s.send_message(msg)
s.quit()
I want to send an email to a gmail account from my computer.
I replace 'localhost' with gmail.com but nothing happens.

What am I doing wrong?
How can I send an email to gmail without logging in to some smtp relay system. I just want to send am email from my computer/python by directly tapping to the gmail smtp listener daemon etc. No accounts, no servers. Is that possible? Please advise.
Reply
#2
Gmail needs as far I know always OAuth2.
You can generate a token for the authorization and use this as password.
Additionally gmail encrypts the traffic, so ssl is needed. Use smtplib.SMTP_SSL instead.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Send email with smtp without using Mimetext mgallotti 0 678 Feb-01-2023, 04:43 AM
Last Post: mgallotti
  email Library: properly send message as quoted-printable malonn 3 1,267 Nov-14-2022, 09:31 PM
Last Post: malonn
  Unable to send email attachments cosmarchy 7 2,444 Mar-09-2022, 09:29 PM
Last Post: bowlofred
  How to make scraper send email notification just once themech25 0 1,362 Nov-08-2021, 01:51 PM
Last Post: themech25
  send email smtp rwahdan 0 1,755 Jun-19-2021, 01:28 AM
Last Post: rwahdan
  Need Outlook send email code using python srikanthpython 3 8,092 Feb-28-2021, 01:53 PM
Last Post: asyswow64
  How to send email using python? Gigux 2 2,784 Jul-04-2020, 07:53 AM
Last Post: Gigux
  I am trying to send an email with python nick235 9 5,202 Jun-29-2020, 06:40 PM
Last Post: nick235
  Smoke detector + send email Brandon99 4 3,912 Sep-12-2018, 11:18 PM
Last Post: Brandon99
  Error while Logging on to outlook email account using Python inside VDI Shilton 0 4,269 Sep-09-2018, 06:53 AM
Last Post: Shilton

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020