Unable to login or send emails through smtp and read mails through imap with python script for (aol)domain

263 Views Asked by At

I have tried with many types of python script but the main issue is , it's unable to login after creating session.Even though my password and email id is right.I tried in many ways, please can anyone mentions what's wrong I'm doing. Was aol mails not encouraging imap and smtp via python script? or any other thing that I'm missing?

This is my imap code for login and reading mails of aol.com

`imap_ssl = imaplib.IMAP4_SSL(
                    host='imap.aol.com', port=993)
print(
    f"Login to  {'[email protected]'}  for REPLY_FLOW")
resp_code, response = imap_ssl.login(
    '[email protected]','my_password')

print("{} got logged in successfully...".format(
    "[email protected]"))`

This is the error I'm getting each time

`examples/yahoo_testing.py"
Login to  [email protected]  for REPLY_FLOW
Traceback (most recent call last):
  File "examples/yahoo_testing.py", line 264, in <module>
    resp_code, response = imap_ssl.login(
  File "/usr/lib/python3.10/imaplib.py", line 612, in login
    raise self.error(dat[-1])
imaplib.IMAP4.error: b'[AUTHENTICATIONFAILED] LOGIN Invalid credentials'`

This is smtp code for aol.com

`import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
addr_to   = '[email protected]'
addr_from = 'Me <[email protected]>'
smtp_server = 'smtp.aol.com'
smtp_user   = '[email protected]'
smtp_pass   = 'my_password'
msg = MIMEMultipart('alternative')
msg['To'] = addr_to
msg['From'] = addr_from
msg['Subject'] = 'Email subject'
text = "Plain text goes here"
html = """\
HTML version goes here.
"""
part1 = MIMEText(text, 'plain')
part2 = MIMEText(html, 'html')
msg.attach(part1)
msg.attach(part2)
s = smtplib.SMTP_SSL(smtp_server)
s.login(smtp_user,smtp_pass)
s.sendmail(addr_from, addr_to, msg.as_string())
s.quit()`

And error getting is

`Traceback (most recent call last):
File " examples/checking_aol.py", line 42, in <module>
s.login(smtp_user,smtp_pass)
File "/usr/lib/python3.10/smtplib.py", line 739, in login
>!     (code, resp) = self.auth(
File "/usr/lib/python3.10/smtplib.py", line 642, in auth
>!     (code, resp) = self.docmd("AUTH", mechanism + " " + response)
File "/usr/lib/python3.10/smtplib.py", line 432, in docmd
return self.getreply()
File "/usr/lib/python3.10/smtplib.py", line 405, in getreply
raise SMTPServerDisconnected("Connection unexpectedly closed")
smtplib.SMTPServerDisconnected: Connection unexpectedly closed`

Instead of this scipt , I tried some others too but none of them able to log me in any with aol mails. Except aol mails , other mails like outlook,gmail and Thunderbird I'm able get in but only for this I'm facing issue. Any help would be greatly appreciated.

0

There are 0 best solutions below