File tree Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Expand file tree Collapse file tree 1 file changed +21
-4
lines changed Original file line number Diff line number Diff line change @@ -13,11 +13,9 @@ def buscar_correo(email_buscar):
13
13
if email_buscar == "[email protected] " :
14
14
return ["Acceso denegado :(" ]
15
15
else :
16
-
16
+
17
17
password = passw
18
- imap_url = 'imap.zoho.eu'
19
-
20
-
18
+ imap_url = 'imap.mail.yahoo.com'
21
19
def obtener_cuerpo (msg ):
22
20
if msg .is_multipart ():
23
21
for part in msg .walk ():
@@ -37,6 +35,25 @@ def obtener_cuerpo(msg):
37
35
cuerpo = cuerpo .decode (charset )
38
36
return cuerpo
39
37
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
+
40
57
return None
41
58
42
59
con = imaplib .IMAP4_SSL (imap_url )
You can’t perform that action at this time.
0 commit comments