Skip to content

Commit 5944d6a

Browse files
committed
to yahoo
1 parent dd9f09b commit 5944d6a

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

mail.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ def buscar_correo(email_buscar):
1313
if email_buscar == "[email protected]":
1414
return ["Acceso denegado :("]
1515
else:
16-
16+
1717
password = passw
18-
imap_url = 'imap.zoho.eu'
19-
20-
18+
imap_url = 'imap.mail.yahoo.com'
2119
def obtener_cuerpo(msg):
2220
if msg.is_multipart():
2321
for part in msg.walk():
@@ -37,6 +35,25 @@ def obtener_cuerpo(msg):
3735
cuerpo = cuerpo.decode(charset)
3836
return cuerpo
3937

38+
# Si no se encontró contenido HTML, buscar contenido de tipo text/plain
39+
if msg.is_multipart():
40+
for part in msg.walk():
41+
content_type = part.get_content_type()
42+
if content_type == 'text/plain':
43+
charset = part.get_content_charset()
44+
cuerpo = part.get_payload(decode=True)
45+
if charset:
46+
cuerpo = cuerpo.decode(charset)
47+
return cuerpo
48+
else:
49+
content_type = msg.get_content_type()
50+
if content_type == 'text/plain':
51+
charset = msg.get_content_charset()
52+
cuerpo = msg.get_payload(decode=True)
53+
if charset:
54+
cuerpo = cuerpo.decode(charset)
55+
return cuerpo
56+
4057
return None
4158

4259
con = imaplib.IMAP4_SSL(imap_url)

0 commit comments

Comments
 (0)