In my application all functions related to sending mail from it work.
The main function reads like:
def send_mail():
nfas=db(db.nfa.nfatype==4).select(db.nfa.ALL,orderby=db.nfa.bedrijf)
for nfa in nfas:
context=dict(nfa=nfa)
message=response.render('clublocatormail/
send_mail.html',context)
recipient=nfa.adres
mail.send(to=[recipient],subject='Controleer uw adresgegevens
in Fitwise',message=message)
return True
The send_mail.html view reads like (I removed the irrelevant parts):
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Template - Single Column</title>
</head>
<style type="text/css" media="screen">
body {
background-color: #eeeeee;
}
</style>
<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0"
class="bg1">
<tr>
<td align="center">
<table width="600" border="0" cellspacing="0" cellpadding="0"
class="bg2">
<tr>
<td class="permission" align="left">
{{if not request.function=='browser_version':}}
<h1>Having trouble viewing this email?
{{=A('View it in your browser',
_href="{{=URL(r=request,a='mock_crm',c='clublocatormail',f='browser_version',args=[nfa.bedrijf])")}}.</
h1>
{{pass}}
</td>
</tr>
<tr>
<td class="header" align="left">
<img src="{{=URL(r=request,c='static',f='template/
header.gif')}}" alt="Header" width="600" height="150" />
</td>
</tr>
<tr>
<td valign="top" class="body">
<table width="100%" border="0" cellspacing="0"
cellpadding="0">
<tr>
<td valign="top" class="mainbar" align="left">
<h2></h2>
<img class="hr"
src="{{=URL(r=request,c='static',f='template/hr.gif')}}" alt="Header"
width="560" height="3" />
<p>{{=nfa.bedrijf}}</p>
<p>{{=nfa.adres}}</
p>
<br />
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign="middle" align="left" class="footer"
height="61">
<p></p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
I based this code on this article:
http://articles.sitepoint.com/article/code-html-email-newsletters
and the templates referred to. I had hoped the view would display
without trouble, but it doesn't. In all mail clients and web based
apps, it displays as plain text, so the html is not rendered. I have
been trying to find out why for two days now, and hope one of you can
come to my rescue.
Kind regards,
Annet.
--
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en.