I have a python API that sends emails. The problem is that I mount an HTML and put a <img>
tag and I put a base64 variable that is src
. But 90% of e-mail services do not support base64. Is there any other way out? Home
Follow 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')
)