Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import socket
- import smtplib
- # Get the current machine's IP address
- ip_address = socket.gethostbyname(socket.gethostname())
- # Set the email address to send the IP address to
- to_email = "[email protected]"
- # Set the SMTP server and login credentials
- smtp_server = "smtp.example.com"
- smtp_username = "username"
- smtp_password = "password"
- # Construct the email message
- message = f"IP address: {ip_address}"
- # Send the email
- server = smtplib.SMTP(smtp_server)
- server.login(smtp_username, smtp_password)
- server.sendmail(smtp_username, to_email, message)
- server.quit
Advertisement
Add Comment
Please, Sign In to add comment