I have python code, I can successfully send emails. But at some point, after 76 number of times python script has sent emails, it gives an error. That's why I wanted to rotate email credentials, so I have two email credentials and after it is 50 I want to rotate account and continue sending from another account.
I copy pasted login script to second function. I am guessing, maybe as in browser I need also do some action of logging out
but put time.sleep in rotating function.
What I realize it does not log in second time. What can be issue?
Here is code;
first function
`def send_mail():
count=0
email = yagmail.SMTP('email id','pass key')
for k,receiver in receivers.iterrows():
email.send(
to=receiver[0],
subject="Inquiry about __ ",
contents='Hi, \n ',
)
count +=1
if count==5:
n += 1
rotating_send(count, list(receivers), body,n)
def rotating_send(count,lst_of_emails,body,n):
time.sleep(33.3)
try:
print('rotate...')
email_id, passkey, m = choosen_email(n)
email = yagmail.SMTP('email id','pass key')
for k, receiver in enumerate(lst_of_emails[count:]):
email.send(
to=receiver,
subject="Inquiry about __ ",
contents=body,
)
print(count, receiver)
count += 1
except SMTPServerDisconnected or SMTPSenderRefused as e:
print('rotate login again')
print(f"email has been sent to {count} users")
n+=1
rotating_send(count,lst_of_emails,body,m+n)