Forum Archive

email sending w/o prompt

jaganat

Is there a way to send an email w/o having to press send during the workflow? Python?

omz

You could use the smtplib module. I've made an example a while ago, demonstrating how to send an image attachment: https://gist.github.com/omz/4073599 -- if you just want to send a regular text email, it's a bit simpler, and you'll probably find a lot of tutorials by googling for "smtplib python".

jaganat

Lost in the Python world... Anyone could please post a standard code to insert in a workflow to send an email build by the action "Compose email" in Editorial?

peterh86

I'm lost in the python world too. Google is our friend. Try something more specific like: Python smtplib send email examples.

Editorial has a website of extra workflows that people share. Try searching there for email.

jaganat

Getting there.... but

I don't know how to insert the workflow variables 'nombre' and 'email' in the script:

import workflow

nombre = workflow.get_variable('nombre')
email = workflow.get_variable('email')

import smtplib

SERVER = "localhost"

FROM = "me@myemail.com"
TO = ["email"] # must be a list

SUBJECT = "Bienvenido a Focus Integral"

TEXT = "Apreciado 'nombre'"

message = """\
From: %s
To: %s
Subject: %s

%s
""" % (FROM, ", ".join(TO), SUBJECT, TEXT)

server = smtplib.SMTP(SERVER)
server.sendmail(FROM, TO, message)
server.quit()