Source Code - Raspberry Pi using the smtplib | Web Scripts | Crax

Welcome To Crax.Pro Forum!

Check our new Marketplace at Crax.Shop

   Login! SignUp Now!
  • We are in solidarity with our brothers and sisters in Palestine. Free Palestine. To learn more visit this Page

  • Crax.Pro domain has been taken down!

    Alternatives: Craxpro.io | Craxpro.com

Source Code Raspberry Pi using the smtplib

Source Code Raspberry Pi using the smtplib

LV
1
 

1ultrapower

Member
Joined
Dec 28, 2023
Threads
10
Likes
3
Awards
4
Credits
3,461©
Cash
0$
import smtplib
from email.mime.text import MIMEText

def send_email(recipient, subject, body):
# SMTP server settings
smtp_server = 'smtp.example.com'
smtp_port = 587
smtp_user = 'your_email@example.com'
smtp_password = 'your_password'

# Create the email message
msg = MIMEText(body)
msg['Subject'] = subject
msg['From'] = smtp_user
msg['To'] = recipient

# Connect to the SMTP server
server = smtplib.SMTP(smtp_server, smtp_port)
server.starttls()
server.login(smtp_user, smtp_password)

# Send the email
server.sendmail(smtp_user, recipient, msg.as_string())

# Close the connection
server.quit()

# Example usage
recipient = 'recipient@example.com'
subject = 'Test email from Raspberry Pi'
body = 'Hello, this is a test email sent from a Raspberry Pi.'

send_email(recipient, subject, body)
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top Bottom