tags:

views:

14

answers:

1

I have python code that looks like below. It works fine when executed manually. But when executed via a cronjob, the email is not being sent. Here is the code:

msg = MIMEMultipart()

msg['From'] = sender
msg['To'] = to
msg['Subject'] = subject
msg.attach(MIMEText(message))

mailServer = smtplib.SMTP("smtp.gmail.com", 587)
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
mailServer.login(login, password)
print mailServer.sendmail(login, to, msg.as_string())
A: 

Maybe your environment in Unix is different when executed manually/from cron.Do a "env >file" in cron and compare to env when running interactively

Mikpa