Bulk Email AWS SES
-
aws ses වල එක පාර ඊමේල් ලිස්ට් එකකට ඊමේල් යවන්න ක්රමයක් තියෙනවද .?
-
ehema nam na bulk email yawanna puluwan software ekak use karanna wenawa, aws ses kiyanne email service ekak
-
Simple python script ekakin bulk yawanna puluwan..
-
@foxmolder otp requests yawalada?
-
@xenon eyala dela thiyena sample code ekakata for loop ekak ekak and array ekak use karala
-
email limit ekak thiyenawa ses wala, oka yawanne one queue ekak widiyata
-
@root eyala time eka manage karanawa. eth bounce rate eka handle karaganna eka thamai amaru.. mage code eka danna puluwan methana kawru hari innawa nam bounce rate eka manage karana script eka ekata ekathu karala improve karanna
-
import smtplib
import email.utils
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMETextfruits = ["[email protected]","[email protected]", ]
for RECIPIENT in fruits:Replace [email protected] with your "From" address.
This address must be verified.
SENDER = '[email protected]' SENDERNAME = 'ex.com'
Replace [email protected] with a "To" address. If your account
is still in the sandbox, this address must be verified.
RECIPIENT = '[email protected]'
Replace smtp_username with your Amazon SES SMTP user name.
USERNAME_SMTP = ""
Replace smtp_password with your Amazon SES SMTP password.
PASSWORD_SMTP = ""
(Optional) the name of a configuration set to use for this message.
If you comment out this line, you also need to remove or comment out
the "X-SES-CONFIGURATION-SET:" header below.
CONFIGURATION_SET = "ConfigSet"
If you're using Amazon SES in an AWS Region other than US West (Oregon),
replace email-smtp.us-west-2.amazonaws.com with the Amazon SES SMTP
endpoint in the appropriate region.
HOST = "email-smtp.us-east-2.amazonaws.com" PORT = 587
The subject line of the email.
SUBJECT = ' '
The email body for recipients with non-HTML email clients.
BODY_TEXT = ("" "" "" )
The HTML body of the email.
BODY_HTML = """<html> </html> """
Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative') msg['Subject'] = SUBJECT msg['From'] = email.utils.formataddr((SENDERNAME, SENDER)) msg['To'] = RECIPIENT
Comment or delete the next line if you are not using a configuration set
msg.add_header('X-SES-CONFIGURATION-SET',CONFIGURATION_SET)
Record the MIME types of both parts - text/plain and text/html.
part1 = MIMEText(BODY_TEXT, 'plain') part2 = MIMEText(BODY_HTML, 'html')
Attach parts into message container.
According to RFC 2046, the last part of a multipart message, in this case
the HTML message, is best and preferred.
msg.attach(part1) msg.attach(part2)
Try to send the message.
try: server = smtplib.SMTP(HOST, PORT) server.ehlo() server.starttls() #stmplib docs recommend calling ehlo() before & after starttls() server.login(USERNAME_SMTP, PASSWORD_SMTP) server.ehlo() server.sendmail(SENDER, RECIPIENT, msg.as_string()) server.close()
Display an error message if something goes wrong.
except Exception as e: print ("Error: ", e) else: print ("Email sent!")