SMTP (Simple Mail Transfer Protocol) is an internet standard protocol used for sending and relaying emails between mail servers.
Elaboration:
- SMTP is a push protocol that works at the application layer of the TCP/IP model.
- Uses port 25 (default), port 465 (SSL-secured), and port 587 (TLS-secured).
- Works with POP3 and IMAP for email retrieval but is strictly for sending emails.
Example:
When you send an email via Gmail, your client uses SMTP to send the message to the recipient’s mail server.
Code Example: (Sending an email using Python’s smtplib
)
pythonCopyEditimport smtplib
server = smtplib.SMTP("smtp.example.com", 587)
server.starttls()
server.login("user@example.com", "password")
server.sendmail("user@example.com", "recipient@example.com", "Subject: Test\n\nHello!")
server.quit()
Leave a Reply