Skip to content

Commit

Permalink
Added delete mail method and example
Browse files Browse the repository at this point in the history
Merge branch 'hp-01-delete-mail'
  • Loading branch information
rklf committed Mar 17, 2024
2 parents 77b1f15 + b09452d commit b1119b9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def main():
for mail_id in mails_ids:
mail = y.get_mail_body(mail_id)
mail.save()
y.delete_mail(mail_id)

if __name__ == "__main__":
main()
Expand Down
17 changes: 17 additions & 0 deletions yopmail/yopmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,20 @@ def get_mail_body(self, mail_id: int, show_image=False, proxies=None) -> Yopmail
req = self.request(f'{self.url}mail', params=params, proxies=proxies, context='mail body')
mail_html = str(BeautifulSoup(req.text, 'html.parser').find('div', {'id': 'mail'}))
return YopmailHTML(mail_html, self.username, mail_id)

def delete_mail(self, mailid, page=1, proxies=None) -> requests.models.Response|None:
params = {
'login': self.username,
'p': str(page), # page
'd': mailid, # mailid? to delete?
'ctrl': '', # mailid or ''
'yp': self.yp,
'yj': self.yj,
'v': self.version,
'r_c': '', # '' or recaptcha?
'id': '', # idaff / sometimes "none" / nextmailid='last' / mailid = id('m%d'%mail_nr)
'ad': '0', # 0 or 1 (advertising i guess)
# 'scrl': '',
# 'yf': '005',
}
return self.request(f'{self.url}inbox', params=params, proxies=proxies, context='delete mail')

0 comments on commit b1119b9

Please sign in to comment.