1) pip install sparkpost
2) I have this inside my private/appconfig.ini:
; smtp address and credentials
[smtp]
server = smtp.sparkpostmail.com:587
sender = [email protected]
login = SMTP_Injection:4dxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx92
3) I have the file modules/mail_send.py with mail_send function (prilohy
means attachment, prijemci means recipients (default are the testing
recipients)):
#!/usr/bin/env python
# -*- coding: utf8 -*-
import os
import mimetypes
from sparkpost import SparkPost
appdir = os.path.join(os.getcwd(), 'applications', 'platby')
sparkpost_key = myconf.take('smtp.login').split(':')[-1].strip()
def mail_send(subject, txt, prilohy=[], prijemci=
[{'email': '[email protected]', 'name': u'Mirek Zvolský na
Googlu'},
{'email': '[email protected]', 'name': u'Mirek Zvolský na Seznamu'}],
styl='text'):
'''
subject, txt - nejlépe unicode objekty
prijemci - viz příklad defaultní hodnoty
styl = 'html'/'text'
přílohy je třeba uložit přes FTP do mail_attachments/ a po odeslání
smazat
'''
attachments = []
for priloha in prilohy:
attachments.append({
'filename': priloha,
'name': os.path.basename(priloha),
'type': mimetypes.guess_type(priloha)[0] or
'application/octet-stream'
})
stylDict = {styl: txt}
sp = SparkPost(sparkpost_key)
sp.transmissions.send(
recipients=[prijemce['email'] for prijemce in prijemci],
from_email=u'Společné Aktivity <[email protected]>',
subject=subject,
attachments=attachments,
**stylDict
)
Dne neděle 11. června 2017 6:12:57 UTC+2 [email protected] napsal(a):
>
> How to integrate SparkPost into web2py? Any info on the api?
>
> What is the mail server setting for SparkPost?
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.