sendmail in standard_error_message
Hi All, When I add a dtml-sendmail block to my standard_error_message, I no longer get the custom error page at all, but the built-in one (headed up "Site Error." I read in the archives that this can be due to the standard_error_message object itself raising an error, but I have put the code in another object and it works fine there. Any idea what I've done wrong? Any help would be greatly appreciated. The code in question is included below. Thanks a lot, Arian Here's the code for the standard_error_message object I'm using, which tests for a NotFound error to treat 404 errors differently. If the sendmail block is removed, it works fine. The mailhost object *does* exist -- the sendmail block works perfectly when used elsewhere. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html40/strict.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title> <dtml-if "error_type=='NotFound'"> Page Not Found - NIWA <dtml-else> Website Error - NIWA </dtml-if> </title> <dtml-var style> </head> <body class="paddedminimal"> <img id="mainlogo" src="/niwalogo300.jpg" alt="NIWA" width="300" height="51"> <dtml-if "error_type=='NotFound'"> <h1>Page Not Found</h1> <p>Sorry – the page requested couldn’t be found.</p> <dtml-sendmail mailhost="mailhost"> To: a.dewit@niwa.co.nz From: web@niwa.co.nz Subject: 404 Error URL: <dtml-var SERVER_URL><dtml-var PATH_INFO><dtml-if QUERY_STRING>?<dtml-var QUERY_STRING></dtml-if> Referrer: <dtml-var HTTP_REFERER> </dtml-sendmail> URL: <dtml-var SERVER_URL><dtml-var PATH_INFO><dtml-if QUERY_STRING>?<dtml-var QUERY_STRING></dtml-if> Referrer: <dtml-var HTTP_REFERER> <dtml-else> <h1>Website Error</h1> <p>Zope has encountered an error while publishing this resource.</p> <p> <strong>Error Type: <dtml-var error_type></strong><br> <strong>Error Value: <dtml-var error_value></strong><br> </p> <hr> <p>Troubleshooting Suggestions</p> <ul> <li>The URL may be incorrect. Try using the links above or the Search box below to find what you're looking for.</li> <dtml-if "error_type in ('KeyError','NameError')"> <li>This resource may be trying to reference a nonexistent object or variable <strong><dtml-var error_value></strong>.</li> </dtml-if> <li>The parameters passed to this resource may be incorrect.</li> <li>A resource that this resource relies on may be encountering an error.</li> </ul> <p>If the error persists please contact us [<a href="mailto:webteam@niwa.co.nz">webteam@niwa.co.nz</a>]. Thank you for your patience. </p> <dtml-comment> Here, events like logging and other actions may also be performed, such as sending mail automatically to the administrator. </dtml-comment> </dtml-if> </body> </html> ------------------------------------------------------------------ Arian de Wit Information Systems Integration Manager NIWA (National Institute of Water & Atmospheric Research) Gate 10 Silverdale Road, Box 11-115, Hamilton, New Zealand 2001 Phone (+64) 7-856 1769 Fax (+64) 7-856 0151 Web http://www.niwa.co.nz ------------------------------------------------------------------
Arian de Wit wrote:
When I add a dtml-sendmail block to my standard_error_message, I no longer get the custom error page at all, but the built-in one (headed up "Site Error." I read in the archives that this can be due to the standard_error_message object itself raising an error, but I have put the code in another object and it works fine there.
Firstup, read this: http://www.zope.org/Members/JohnC/StandardErrorMessage I would guess at a security problem. See if an anonymous user can execute your template... cheers, Chris
Hi Chris, Thanks for your response.
Firstup, read this:
Yep, read that -- it's where I started from.
I would guess at a security problem. See if an anonymous user can execute your template...
I found a workaround which was to use the smtphost= instead of mailhost=, so I guess the security problem is with the mailhost object. Now opened that up to allow "View" and "Access Contents Info" for Anon and Authenticated, but still no joy. I guess I'll just stick with the smtphost= attribute instead. Probably best not to have standard_error_message dependent on too many other objects anyway... I have copied this to the list for others to see (perhaps when searching the archives many moons from now)? Hope that's acceptable netiquette... Regards, Arian ------------------------------------------------------------------ Arian de Wit Information Systems Integration Manager NIWA (National Institute of Water & Atmospheric Research) Gate 10 Silverdale Road, Box 11-115, Hamilton, New Zealand 2001 Phone (+64) 7-856 1769 Fax (+64) 7-856 0151 Web http://www.niwa.co.nz ------------------------------------------------------------------
participants (2)
-
Arian de Wit -
Chris Withers