0
I have a python API that sends emails. The problem is that I mount an HTML and tag <img>
and I put a clothesline from Base64 which is the src
. However 90% of email services do not accept Base64. Is there any other way out ?
Follows the Code:
def show_logotipo():
from PIL import Image
import StringIO
import base64
logotipo = db(Parametros_Gerais.id == 1).select().first().logotipo
pic = Image.open(os.path.join(request.folder,'uploads',logotipo))
buf= StringIO.StringIO()
pic.save(buf, format='PNG')
buf.seek(0)
buf_s = buf.read()
logo_final = base64.b64encode(buf_s)
return logo_final
logo_final = show_logotipo()
mail_body = "<html>"\
"<header>"\
"<style>"\
"span{"\
"font-family: serif;"\
"font-weight:bold;"\
"font-style: 18px;"\
"}"\
"p{"\
"font-family: serif;"\
"font-style: 18px;"\
"}"\
"</style>"\
"</header>"\
"<body>"\
"<h1>Você foi convidado a uma nova sala de conferencia</h1>"\
"<p><span>Número da conferencia:</span> "+str(busca_conf[0]['confno'])+"</p>"\
"<p><span>Senha de acesso:</span> "+str(user_pw)+"</p>"\
"<p><span>Horario:</span> "+str(busca_conf[0]['starttime'].strftime('%Y-%m-%d %H:%M'))+"</p>"\
"<p><span>Qualquer dúvida sobre essa conferencia, envie um e-mail para:</span> "+email_admin+"</p>"\
"<p>--</p>"\
"<img src='data:image/png;base64,"+logo_final+"'>"\
"</body>"\
"</html>"
print mail_body
mail.send(
to=item_form['email'],
subject='Convite para uma nova sala de Conferencia',
message=mail_body,
attachments=mail.Attachment('/var/www/audio_conf.ics')
)
I think it will not solve your problem, but sometimes it gives you a light... https://answall.com/questions/286570/imagem-em-e-mail-html?noredirect=1#comment583592_286570
– hugocsl