45 lines
1.1 KiB
Python
45 lines
1.1 KiB
Python
from email import message
|
|
# using server service
|
|
import smtplib
|
|
# for sending mail in that shape
|
|
from email.message import EmailMessage
|
|
# dotenv for using environment variables needed pip install python-dotenv
|
|
from dotenv import load_dotenv
|
|
# for importing files
|
|
import os
|
|
|
|
|
|
|
|
|
|
|
|
# we can use variable with list of email adress for msg['To'] for receivers
|
|
# receiver = ["misij83692@carsik.com",]
|
|
|
|
|
|
msg = EmailMessage()
|
|
# Subject should be dinamicly to add subject from olx
|
|
msg['Subject'] = 'KIVI-CARS'
|
|
msg['From'] = 'kivi-cars.ba'
|
|
# Below is generated email adress using https://temp-mail.org/
|
|
msg['To'] = ["girolag234@eosbuzz.com","tojebik898@3dinews.com"]
|
|
msg_body = """Pozdrav,
|
|
Ovo je automatski generisana poruka u svrhu testiranja naseg servisa
|
|
Vaš Kivi-cars tim! """
|
|
msg.set_content(msg_body)
|
|
|
|
#environment variables
|
|
load_dotenv()
|
|
|
|
sender = os.getenv("EMAIL_HOST_USER")
|
|
password = os.getenv("EMAIL_HOST_PASSWORD")
|
|
host = os.getenv("EMAIL_HOST")
|
|
port = os.getenv("EMAIL_PORT")
|
|
|
|
server = smtplib.SMTP(host, port)
|
|
server.starttls()
|
|
|
|
server.login(sender,password)
|
|
print("logged in...")
|
|
server.send_message(msg)
|
|
print("email has beeen sent!")
|