ezmail::sendmail implementation does not work with safe_mode

Author Message

Huib Kleinhout

Tuesday 06 May 2003 7:51:38 am

Hi, the sendmail transport of ezmaildoes not work with safe_mode because safe mode disables the fifth parameter of mail() (see http://php.net/manual/function.mail.php for details).
It took some time to find it out because ezpublish does not write a debug message when mail fails but now I changed sendmail::sendMail a bit so it detects safe_mode:

function sendMail( &$mail )
{
$ini =& eZINI::instance();
$emailSender = $ini->variable( 'MailSettings', 'EmailSender' );
if ( preg_match("/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+$/", $emailSender ) )
$mail->addExtraHeader("From",$emailSender);
else
unset($emailSender);
$extraHeaders = $mail->headerText( array( 'exclude-headers' => array( 'To', 'Subject' ) ) );
$message = $mail->body();
if ( ( ini_get( 'safe_mode' ) ) || ( empty($emailSender) ) ) //safe_mode enabled or no sender specified
return mail( $mail->receiverEmailText(), $mail->subject(), $message, $extraHeaders);
else
return mail( $mail->receiverEmailText(), $mail->subject(), $message, $extraHeaders, '-f' . $emailSender );
}

(As you might notice I've added a 'From' header.)
I don't know where to send patches and if it's the best solution for this problem but it might help someone facing the same problem. Most ISP's do have safe_mode enabled.

cheers, Huib Kleinhout

Marco Zinn

Tuesday 06 May 2003 1:11:47 pm

Well,
I had a small discussion with the ezCrew: ezP2 and ezP3 require safe_mode to be off.

My Interpretation: If it is on, it won't work at all or won't work as expected.
IF someone collects the patches to run it with safe_mode, here is my part:
You need to change all Shell-Execute Call, ie. from PHP to ImageMagick. I had some real problem while trying to have ezP2 running with safemode on, because calling ImageMagick didn't work because of the > character.
This will effect everything, that calls system functions, I guess (like file copying etc), as the arguments will get escaped for security reasons, when safemode is on.

For me, _I_ gave up my trials with safemode and turned it off, but I can do it, as it is our own server.

Marco
http://www.hyperroad-design.com

Huib Kleinhout

Wednesday 07 May 2003 5:28:26 am

Hmmm, ezpublish indeed does not like safe mode, I'm running into image problems (with BD) again.
I can understand that eZ systems doesn't want to support safe_mode because most of the big sites run dedicated hardware and can turn it off. But all vhost-providers seem to use safe_mode, so using ezpublish at sub 100 euro p/m seems to be quite impossible. (Somebody knows a Dutch hosting service with safe_mode off???)

Thanks for your reply. But I don't think I'm going to start patching ez publish while ez systems ignores it.

Karsten Jennissen

Wednesday 07 May 2003 5:35:03 am

Hi Huib,

even though its German, you might want to consider renting a Puretec (http://www.puretec.de) dedicated server. Its only ยค49 a month, or try Server4free (http://www.server4free.de/), they have good offers. Even though they are both rather cheap offers, they are ok. I host with Puretec and a friend of mine with Server4free. No complaints yet. :-)

Other than that, there should be safemode off virtual host offers. Anyone?

Karsten

Jan Borsodi

Wednesday 07 May 2003 5:43:58 am

We will accept patches for eZ publish if they do not break anything and fits into the kernel. Just create a new contribution and add the patch there (Please create a diff file which can sent to the patch program).

As for safe_mode we will continue to find solutions to make eZ publish work with it on. However for eZ publish to run in safe_mode you must make sure that the site is properly setup (like permissions, proper upload directory etc.) since eZ publish cannot do this automatically.

Besides, eZ publish is open source, isn't it?

--
Amos

Documentation: http://ez.no/ez_publish/documentation
FAQ: http://ez.no/ez_publish/documentation/faq

Huib Kleinhout

Wednesday 07 May 2003 6:32:32 am

Karsten: Thanks for your advice. These german providers are indeed much cheaper than the dutch providers I looked at.
Maybe some Dutch providers also charge such low rates.

Jan Borsodi:
Will patches with things like
if ( ini_get( 'safe_mode' ) {
be accepted then?
I do not really feel like creating an another ezp branch. But if safe_mode only causes minor problems (which seem to be the case right now) and ez systems wants to take into account safe_mode use, I will continue debugging and patching.

Setting up the proper permissions is indeed a tricky issue but a php-based installer could do that.
So it looks like it's possible to use ezp in safe_mode without loosing major functionality.
Well, I'll start with this then http://ez.no/developer/ez_publish_3/forum/install_configuration/image_handling_with_gd2/re_image_handling_with_gd2
;-)

Marco Zinn

Wednesday 07 May 2003 2:29:58 pm

<Ad on>
Huib, if you want to give it a try: We have one of the Root-Servers at 1&1 and run some ezPublish sites there (2.2 and 3.0.x).
If you are interessted to set up a site there, mail me at marco.zinn@gmx.de and we will speak about prices (< 49 Euro / m)

<Ad off>

Of course, this is valid for everyone...

Regards,

Marco

Marco
http://www.hyperroad-design.com

Huib Kleinhout

Thursday 08 May 2003 1:48:42 am

Thanks for your offer Marco,
But I'll first try to get ezp running on my current host because the only problem seems to be that images aren't converted.
It would be nice if I could get ezp fully running on safe mode.

I have had some bad experiences with moving domains so I'll try to avoid that unless it's really necessary.

Huib

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 10:23:38
Script start
Timing: Jan 18 2025 10:23:38
Module start 'layout'
Timing: Jan 18 2025 10:23:38
Module start 'content'
Timing: Jan 18 2025 10:23:38
Module end 'content'
Timing: Jan 18 2025 10:23:39
Script end

Main resources:

Total runtime0.7117 sec
Peak memory usage4,096.0000 KB
Database Queries76

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0059 589.2891152.6563
Module start 'layout' 0.00590.0030 741.945339.5078
Module start 'content' 0.00880.7015 781.4531692.6328
Module end 'content' 0.71030.0014 1,474.085920.0938
Script end 0.7117  1,494.1797 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00330.4599160.0002
Check MTime0.00130.1891160.0001
Mysql Total
Database connection0.00110.157310.0011
Mysqli_queries0.636589.4331760.0084
Looping result0.00070.0984740.0000
Template Total0.683696.020.3418
Template load0.00200.280320.0010
Template processing0.681695.762220.3408
Template load and register function0.00020.022210.0002
states
state_id_array0.00090.123110.0009
state_identifier_array0.00070.099820.0004
Override
Cache load0.00180.2492770.0000
Sytem overhead
Fetch class attribute can translate value0.00050.076340.0001
Fetch class attribute name0.00100.1339110.0001
XML
Image XML parsing0.00290.414540.0007
class_abstraction
Instantiating content class attribute0.00000.0040150.0000
General
dbfile0.00230.3243290.0001
String conversion0.00000.001140.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
8content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 41
 Number of unique templates used: 6

Time used to render debug report: 0.0001 secs