Send email using python script in Plone

If you dont want to hardcode the Mail Host id into your script and want to be able to send email to someone from within a (Script) Python this script will do it.

try:
    mailhost=getattr(context, context.superValues('Mail Host')[0].id)
except:
    raise AttributeError, "cant find a Mail Host object"

mMsg = 'a testful email message n that contains a few line breaks. n ~runyaga'
mTo = 'runyaga@abc.com'
mFrom = 'runyaga@xyz.com'
mSubj = 'mail subject'

mailhost.send(mMsg, mTo, mFrom, mSubj)
Share

Comments

  1. Hi,

    If i want to send a email using python on Plone and also want to cc some folks what is the function i should be using to do the same. I understand that mailhost.send or mailhost.simple_send would not allow me to cc somebody!

    Thanks in advance
    Ganga

  2. I can’t see any functionality in this function to send multiple mail. But you can try add-on products for this. Have a look these products I have listed below find the best according to your requirements.

    http://plone.org/products/cpimailnotification/
    http://plone.org/products/securemailhost/releases/1.0.3/

    🙂

Leave a Reply

Your email address will not be published. Required fields are marked *