10 minutowy mail wysyłanie

Here is a 10-minute email sending script in Python using the smtplib library:

import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

def send_email(subject, message, from_addr, to_addr, password):
    msg = MIMEMultipart()
    msg['From'] = from_addr
    msg['To'] = to_addr
    msg['Subject'] = subject

    body = message
    msg.attach(MIMEText(body, 'plain'))

    server = smtplib.SMTP('smtp.gmail.com', 587)
    server.starttls()
    server.login(from_addr, password)
    text = msg.as_string()
    server.sendmail(from_addr, to_addr, text)
    server.quit()

subject = "Test Email"
message = "This is a test email sent using Python."
from_addr = "[email protected]"
to_addr = "[email protected]"
password = "your_email_password"

send_email(subject, message, from_addr, to_addr, password)

Before running this script, make sure to:

  1. Replace [email protected] with your actual Gmail address.
  2. Replace [email protected] with the recipient's email address.
  3. Replace your_email_password with your actual Gmail password.
  4. Install the smtplib library by running pip install smtplib in your terminal.

This script will send an email with the specified subject, message, from address, to address, and password. The email will be sent using the Gmail SMTP server.

Note: If you're using Gmail, you may need to allow less secure apps to access your account. You can do this by going to your Google Account settings and enabling the "Less secure app access" option. However, this is not recommended as it can compromise your account security. A better option is to generate an App Password and use that instead of your regular password.