this post was submitted on 02 Apr 2025
8 points (100.0% liked)

Cybersecurity

7137 readers
197 users here now

c/cybersecurity is a community centered on the cybersecurity and information security profession. You can come here to discuss news, post something interesting, or just chat with others.

THE RULES

Instance Rules

Community Rules

If you ask someone to hack your "friends" socials you're just going to get banned so don't do that.

Learn about hacking

Hack the Box

Try Hack Me

Pico Capture the flag

Other security-related communities !databreaches@lemmy.zip !netsec@lemmy.world !securitynews@infosec.pub !cybersecurity@infosec.pub !pulse_of_truth@infosec.pub

Notable mention to !cybersecuritymemes@lemmy.world

founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
[–] opalfrost@friendica.world 0 points 1 month ago

@taladar
consider validate.email and py3-validate-email
+````import re
import smtplib
from email.mime.text import MIMEText
from email.mime.multipart import MIMEMultipart

server = smtplib.SMTP_SSL('smtp.example.com', 465)

try:
server.login('sender@example.com', 'password')

msg = MIMEMultipart()
msg['From'] = 'sender@example.com'
msg['Subject'] = 'Test email'

body = 'This is a test email sent using Python.'
msg.attach(MIMEText(body, 'plain'))

email_list = [
    'recipient1@example.com',
    'recipient2@example.com',
    'recipient3@example.com'
]

for email in email_list:

    email_regex = r'^\w+@[a-zA-Z_]+?\.[a-zA-Z]{2,3}$'
    if re.match(email_regex, email):

        msg['To'] = email
        server.sendmail('sender@example.com', email, msg.as_string())
        print(f'Sent test email to {email}')
    else:
        print(f'Invalid email: {email}')

except Exception as e:
print(f'Error: {e}')

finally:
server.quit()````

now the DNS erno is there, totally normal as I display here and just used examples.
w3schools.com/python/trypython…