Hello Abdulaziz Yassin,
The issue is with the runbook python script you are trying to execute. Because I have tested with couple of runbooks and it worked fine as expected.
Can you try below sample code once if this is sending emails correctly.
import smtplib
from email.mime.text import MIMEText
def send_email(to_address, subject, body):
msg = MIMEText(body)
msg['Subject'] = 'subject'
msg['From'] = '<mailid>'
msg['To'] = to_address
with smtplib.SMTP('smtp.office365.com', 587) as server:
server.starttls()
server.login('******@domain.com', 'password')
server.sendmail(msg['From'], [msg['To']], msg.as_string())
If this is helpful, please click on Accept Answer and upvote it. If you still have any queries further, please click on comment.