Contents
config.json can include mailer section:
"applications": ["pserver.mailer"], "mailer": { "default_sender": "foo@bar.com", "endpoints": { "default": { "type": "smtp", "host": "localhost", "port": 25 } } }
For development/debugging, you can use a console print mailer:
"applications": ["pserver.mailer"], "mailer": { "default_sender": "foo@bar.com", "endpoints": { "default": { "type": "smtp", "host": "localhost", "port": 25 } }, "utility": "pserver.mailer.utility.PrintingMailerUtility" }
POST http://localhost:8080/zodb/plone/@mailer
- {
- "sender": "foo@bar.com", "recipient": "john@doe.com", "subject": "Some subject", "text": "Hello"
}
pserver.mailer defines a permission mailer.SendMail which, by default, only the plone.SiteAdmin role is assigned.
You can also directly use the mailer in your code:
from zope.component import queryUtility from pserver.mailer.interfaces import IMailer mailer = queryUtility(IMailer) await mailer.send(recipient='john@doe.com', subject='This is my subject', text='Body of email')