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.