Login Register






Adding a sleep or delay function to a Python script filter_list
Author
Message
Adding a sleep or delay function to a Python script #1
I have got a couple of Python mailing scripts but trying to figure out a way to alter the scripts so it sends out mail from a mailing list one after the other instead of all at once, maybe like a few seconds delay after each mail is sent, i could upload the scripts here for a closer look if required...

Reply

RE: Adding a sleep or delay function to a Python script #2
Thread moved from The Lounge forum, accordingly to Python.
[Image: AD83g1A.png]

Reply

RE: Adding a sleep or delay function to a Python script #3
Can you post your code in a code sample for us?
That way we can give you an example of something that might work for you.
(This post was last modified: 04-18-2020, 05:41 AM by Blue.)
[Image: xlbdwZT.png]

[+] 1 user Likes Blue's post
Reply

RE: Adding a sleep or delay function to a Python script #4
(04-18-2020, 05:41 AM)Blue Wrote: Can you post your code in a code sample for us?
That way we can give you an example of something that might work for you.
Code:
import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email import encoders email_user = 'your_email' email_password = 'your_password' email_send = 'recipient_email' subject = 'subject' msg = MIMEMultipart() msg['From'] = email_user msg['To'] = email_send msg['Subject'] = subject body = 'Hi there, sending this email from Python!' msg.attach(MIMEText(body,'plain')) filename='filename' attachment =open(filename,'rb') part = MIMEBase('application','octet-stream') part.set_payload((attachment).read()) encoders.encode_base64(part) part.add_header('Content-Disposition',"attachment; filename= "+filename) msg.attach(part) text = msg.as_string() server = smtplib.SMTP('smtp.gmail.com',587) server.starttls() server.login(email_user,email_password) server.sendmail(email_user,email_send,text) server.quit()

Reply

RE: Adding a sleep or delay function to a Python script #5
Code:
import time time.sleep(1) #sleeps for 1second then continues
[Image: 1yEDa5A.gif]
2019-05-12

[+] 1 user Likes slothic's post
Reply

RE: Adding a sleep or delay function to a Python script #6
time.sleep(secondshere)

would be easy way to do it.

Reply