sending email reminders with bcc to phuoc
This commit is contained in:
@@ -150,9 +150,11 @@ def email_rappels(request, objet, corps, destinataire, societe):
|
||||
msg['Subject'] = "[Ent. Dumas] " + objet
|
||||
msg['From'] = smtp_user
|
||||
msg['To'] = destinataire
|
||||
msg['Bcc'] = "phuoc@caotek.fr"
|
||||
msg.set_content(corps, subtype='html')
|
||||
|
||||
# Try to log in to server and send email
|
||||
err = ''
|
||||
try:
|
||||
server = smtplib.SMTP(smtp_server,smtp_port)
|
||||
server.starttls(context=context) # Secure the connection
|
||||
@@ -162,16 +164,18 @@ def email_rappels(request, objet, corps, destinataire, societe):
|
||||
print("sendmail -> OK")
|
||||
|
||||
except Exception as e:
|
||||
# Print any error messages to stdout
|
||||
print(e)
|
||||
# Just print(e) is cleaner and more likely what you want,
|
||||
# but if you insist on printing message specifically whenever possible...
|
||||
err = repr(e)[0:400]
|
||||
insert_log(request, 'MAILER', "- ERROR : %s, TO : %s" % (err, destinataire))
|
||||
finally:
|
||||
server.quit()
|
||||
|
||||
return 0
|
||||
return len(err)
|
||||
|
||||
def email_rapport(request):
|
||||
NOW = datetime.now()
|
||||
corps = "<html><body><p>=============================================</p>"
|
||||
corps = "<!DOCTYPE html><html><body><p>=============================================</p>"
|
||||
corps += "<p>Rapport du traitement de nuit du " + NOW.strftime('%d/%m/%Y - %H:%M') + "</p>"
|
||||
corps += "<p>=============================================</p><p></p><p>"
|
||||
|
||||
@@ -190,15 +194,12 @@ def email_rapport(request):
|
||||
|
||||
|
||||
def send_mail(request, expediteur, destinataires, objet, corps):
|
||||
body = """
|
||||
|
||||
%s
|
||||
""" % (corps)
|
||||
body_html = Attachment(data=corps, transfer_encoding="base64", disposition='inline')
|
||||
|
||||
message = Message(subject=objet,
|
||||
sender=expediteur,
|
||||
recipients=destinataires,
|
||||
html=body)
|
||||
html=body_html)
|
||||
mailer = get_mailer(request)
|
||||
msg = ''
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user