haebby Posted August 12, 2005 Share Posted August 12, 2005 I'm using the Postie plugin together with Wordpress for mobile blogging (i.e. posting photos from my cell phone on the road). Works great. Postie requires periodic running of a php script named get_mail.php. I set-up a cron job at another Web hoster to call this script periodically. The cron job looks like */30 * * * * /usr/bin/lynx --source http://<my domain>/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1 with <my domain> being hosted by TCH. As we know, TCH doesn't support lynx or wget, so I tried to set-up a similar cron job on TCH using php by specifying */30 * * * * php -q ~/public_html/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1 This works and the script is executed (i.e. the emails are fetched from the POP# account). However, postie now fails to create thumbnails from the picturs and fails to adjust the size of the posted images. My *guess* is that it has do with GD not being found when the script is executed from php rather than through the Web server via lynx or wget. Anyone any ideas? I would hate having to switch to a Web hoster who supports lynx/wget just because of this. Thanks!! Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 12, 2005 Share Posted August 12, 2005 Welcome to the forums, haebby! My first guess would be that there may be a problem with the script not being run from the same directory the script is located in. I would suggest adding the following code to the very beginning of get_mail.php, just after the '<?php' line: >chdir(dirname($_SERVER['argv'][0])); If that doesn't solve your problem, you're going to need some sort of error message to give a hint as to what the problem is. There is a lot of code and it's not immediately apparent where a problem like this could be coming from. I'd suggest sending a test e-mail to your account, then modify your cron job command to not send its output to /dev/null: >php -q ~/public_html/wp-content/plugins/postie/get_mail.php 2>&1 When the cron job runs, you *will* get an e-mail containing output from the script. Hopefully there would be one or more error messages within the output that would tell you what the problem is. Hope this helps... Quote Link to comment Share on other sites More sharing options...
TCH-Rob Posted August 12, 2005 Share Posted August 12, 2005 Welcome to the forums, haebby Quote Link to comment Share on other sites More sharing options...
abinidi Posted August 12, 2005 Share Posted August 12, 2005 TCH-David, You are so smart! -- and helpful!! Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted August 12, 2005 Share Posted August 12, 2005 Welcome to the forums, haebby Quote Link to comment Share on other sites More sharing options...
TCH-Thomas Posted August 12, 2005 Share Posted August 12, 2005 Welcome to the forum, haebby. Quote Link to comment Share on other sites More sharing options...
haebby Posted August 12, 2005 Author Share Posted August 12, 2005 Welcome to the forums, haebby! David - thanks for your response! My first guess would be that there may be a problem with the script not being run from the same directory the script is located in. I would suggest adding the following code to the very beginning of get_mail.php, just after the '<?php' line: >chdir(dirname($_SERVER['argv'][0])); Based on one of your earlier posts in another thread, I alreay tried that. Unfortunatly, it doesn't solve the problem.If that doesn't solve your problem, you're going to need some sort of error message to give a hint as to what the problem is. There is a lot of code and it's not immediately apparent where a problem like this could be coming from. I'd suggest sending a test e-mail to your account, then modify your cron job command to not send its output to /dev/null: >php -q ~/public_html/wp-content/plugins/postie/get_mail.php 2>&1 When the cron job runs, you *will* get an e-mail containing output from the script. Hopefully there would be one or more error messages within the output that would tell you what the problem is. Yup, also tried that one already. I do receive an email, but the output doesn't indicate any error. It's the same output I get when calling the script through lynx. However, the result is different - no thumbnails are created I'm not a php expert, hope is it's something trivial I overlook... Quote Link to comment Share on other sites More sharing options...
TCH-Don Posted August 12, 2005 Share Posted August 12, 2005 Welcome to the forums, haebby Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 12, 2005 Share Posted August 12, 2005 I set up a WP install from scratch, created an e-mail account for the Postie plugin to use, and installed the Postie plugin per the instructions. I set up the cron job a little differently than what the instructions recommend though: 1) I set the permissions on wp-content/plugins/postie/get_mail.php to 0755 so it could be executed directly, as get_mail.php has a proper shebang line at the beginning of the script: >#!/usr/bin/php -q 2) I used the following as the 'Command to run' in the cron job: >/home/cpanelName/public_html/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1 a) No 'php -q', since that's in the get_mail.php script already. b) No '~' shortcut for the '/home/cpanelName' directory. c) Replace 'cpanelName' with your CPanel username. I ran get_mail.php in a cron job a few times with test e-mails I sent to the appropriate e-mail account, and it successfully created thumbnails from the pictures I attached as expected. I did not have to modify the get_mail.php script at all. If the script can't find GD on the server, I would suspect that GD is not installed on the server. I don't think this is likely, but it's not hard to check. (You can run a script with the phpinfo() function in it, or you can browse to http://serverXX.totalchoicehosting.com/phpInfo.php, where 'XX' is your server number.) I would suggest going over the Postie plugin settings again and make sure you have its settings configured properly (such as 'Resize Large Images' set to 'Yes'). Also, check the size of the images you're attaching to your e-mails - the width of the image must be greater than the 'Maximum Image Width' setting (default: 400px) in order for a thumbnail to be created. Quote Link to comment Share on other sites More sharing options...
haebby Posted August 13, 2005 Author Share Posted August 13, 2005 I set up a WP install from scratch, created an e-mail account for the Postie plugin to use, and installed the Postie plugin per the instructions. [...] <{POST_SNAPBACK}> David - thanks so much for spending so much effort on this. Appreciate yor help! I followed all your instructions, but unfortunately, I still have the same problem. Not knowing php, I digged a little bit deeper into "postie-functions.php" and added printouts at severl places. What I found is that the problem seems to be with the function "imagecreatefromgif" not being found. "postie-functions.php" has a function named "HasFunctions(...)". This function returns "false" when checking for 'imagecreatefromgif'. For all other functions, it seems to check OK. This is weird, don't know what happens here. When I remove the check for 'imagecreatefromgif', the script continues, the thumbnail generation is invoced, but some other problems occur I'm looking in now. Any idea why the test for function 'imagecreatefromgif' fails? I'm running this in server 82, which seems to have GD installed. Thanks! Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 14, 2005 Share Posted August 14, 2005 Not knowing php, I digged a little bit deeper into "postie-functions.php" and added printouts at severl places. What I found is that the problem seems to be with the function "imagecreatefromgif" not being found. "postie-functions.php" has a function named "HasFunctions(...)". This function returns "false" when checking for 'imagecreatefromgif'. For all other functions, it seems to check OK. This is weird, don't know what happens here. <{POST_SNAPBACK}> I extracted the HasGDInstalled() and HasFunctions() functions from postie-functions.php and put them into my own little test script: ><?php function HasGDInstalled($display = true) { $function_list = array("getimagesize", "imagecreatefromjpeg", "imagecreatefromgif", "imagecreatefrompng", "imagecreatetruecolor", "imagecreatetruecolor", "imagecopyresized", "imagejpeg", "imagedestroy"); return(HasFunctions($function_list,$display)); } /** * Handles verifing that a list of functions exists * @return boolean * @param array */ function HasFunctions($function_list,$display = true) { foreach ($function_list as $function) { if (!function_exists($function)) { /* if ($display) { print("<p>Missing $function"); } */ return(false); } } return(true); } echo HasGDInstalled(); ?> On my server, this script displays 1 (true), indicating that all of the functions listed in the HasGDInstalled() function are available. If this script indicates that 'imagecreatefromgif' is missing (not available) when run on your server, the only explanation I can think of is that one or more of the underlying GD libraries required for GIF support is not installed. When I remove the check for 'imagecreatefromgif', the script continues, the thumbnail generation is invoced, but some other problems occur I'm looking in now. <{POST_SNAPBACK}> I wouldn't recommend doing that. Any idea why the test for function 'imagecreatefromgif' fails? I'm running this in server 82, which seems to have GD installed. Thanks! <{POST_SNAPBACK}> My suggestions from here would be to try running the test script I have above. If it indicates that something is missing from GD, I think your options would be 1) open a Help Desk ticket and ask them to investigate, or 2) configure the Postie plugin to use ImageMagick instead of GD to resize your images (set 'Use ImageMagick' to 'Yes'). Quote Link to comment Share on other sites More sharing options...
haebby Posted August 15, 2005 Author Share Posted August 15, 2005 I extracted the HasGDInstalled() and HasFunctions() functions from postie-functions.php and put them into my own little test script:[...] On my server, this script displays 1 (true), indicating that all of the functions listed in the HasGDInstalled() function are available. If this script indicates that 'imagecreatefromgif' is missing (not available) when run on your server, the only explanation I can think of is that one or more of the underlying GD libraries required for GIF support is not installed. I put your script on my server. Here's the result I kind of expected based on my previous experience: (1) When I call the script through a browser (i.e. typing in http://<mydomain>/test.php in my broswer), the result is the expected "1", i.e. everything is fine and looks good. (2) When I set up a cron job like "php -q /home/<my-cpanel-name>/public_html/test.php", i.e. calling the exact same .php file, but now through a cron job, I receive the "Missing imagecreatefromgif", just as I did before. Any idea what the reason might be (or what I'm messing up here)? I wouldn't recommend doing that. Me neither Was just curious what happens, as my images are not gif and so I wouldn't expect this function to be used anyway. Was just curious what happens. Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 15, 2005 Share Posted August 15, 2005 Any idea what the reason might be (or what I'm messing up here)? <{POST_SNAPBACK}> The only thing I can figure is that the command line version of PHP is not built the same as the web server version, or there's some options that aren't the same between the two versions. You could try running the following script: ><?php phpinfo(); ?> ...from both a browser window and a cron job, then compare them and see if there's any significant differences (particularly in the 'GD' section). Other than that, I think you'd need to get the Help Desk to take a look at your server and see if they can tell what's wrong. Quote Link to comment Share on other sites More sharing options...
haebby Posted August 15, 2005 Author Share Posted August 15, 2005 You could try running the following script:[...] ...from both a browser window and a cron job, then compare them and see if there's any significant differences (particularly in the 'GD' section). <{POST_SNAPBACK}> Yup, there's indeed a different in output when running the script from a browser window or a cron job. When run from a browser the GD section reports GD Support enabled GD Version bundled (2.0.28 compatible) FreeType Support enabled FreeType Linkage with freetype GIF Read Support enabled GIF Create Support enabled JPG Support enabled PNG Support enabled WBMP Support enabled XBM Support enabled while when run from a cron job, it only reports GD Support enabled GD Version 1.6.2 or higher FreeType Support enabled FreeType Linkage with freetype JPG Support enabled PNG Support enabled WBMP Support enabled Most notably, there's a difference in GD versions, and the former als reports a "bundled" version. GIF support is also missing in hte later. Guess I''ve to open a ticket to get this fixed.. David - thanks much for your help. Awesome support! Hope the help folks will be able to solve the issue. Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted August 15, 2005 Share Posted August 15, 2005 The 1.6.2 version of GD would explain why you don't have GIF support. This is from the 'Image Functions' section of the PHP manual: Versions of GD older than gd-1.6 support GIF format images, and do not support PNG, where versions greater than gd-1.6 and less than gd-2.0.28 support PNG, not GIF. GIF support was re-enabled in gd-2.0.28. I suspect the older version of GD may explain the other issues you were having when you removed the check for 'imagecreatefromgif'. Quote Link to comment Share on other sites More sharing options...
haebby Posted August 16, 2005 Author Share Posted August 16, 2005 David - thanks much for all your help in figuring this out. Awesome support. I submitted a ticket this evening and a few minutes later the problem was solved - PHP was recompiled on said server and the script runs properly now. Excellent support by TCH. Terrific support by David! BIG THANKS. [Now I feel good again about having referred five of my colleagues to TCH Quote Link to comment Share on other sites More sharing options...
valerie Posted April 13, 2006 Share Posted April 13, 2006 Hi. I'm trying to get this plugin working too. My site is hosted by TCH. I followed the above instructions and inserted the following as a crontab: /home/.../public_html/wordpress/wp-content/plugins/postie/get_mail.php >/dev/null 2>&1 I then sent a message to the appropriate email address. I checked and it arrived in the inbox. I ran the script manually through the wordpress interface and it appeared with no trouble. Then I sent another message but I waited for the crontab to work. And it doesn't do anything. Shouldn't I at least get an error email sent to my admin email address? Any ideas on how I can find out what's wrong--or fix it? Thanks! Quote Link to comment Share on other sites More sharing options...
TweezerMan Posted April 13, 2006 Share Posted April 13, 2006 The ">/dev/null" part of your cron command causes all output and errors to be discarded, so there would be nothing for cron to send you. If you want to see if there's any errors being reported, you'd need to temporarily remove that part of the cron command and test it again. Quote Link to comment Share on other sites More sharing options...
valerie Posted April 14, 2006 Share Posted April 14, 2006 (edited) Thanks. Here's the error message I get: /bin/sh: -c: line 1: syntax error near unexpected token `newline' /bin/sh: -c: line 1: `/home/.../public_html/wordpress/wp-content/plugins/postie/get_mail.php >' Here's the code I put in the crontab: /home/.../public_html/wordpress/wp-content/plugins/postie/get_mail.php > Any ideas? SOLVED: I deleted the > at the end and now everything works. I still don't know why the old on didn't work, though. But I'm not complaining! This is what I have in there now: /home/.../public_html/wordpress/wp-content/plugins/postie/get_mail.php > /dev/null Edited April 14, 2006 by valerie Quote Link to comment Share on other sites More sharing options...
TCH-Bruce Posted April 14, 2006 Share Posted April 14, 2006 The ">" is a redirect symbol. Leaving it there with nothing following it would result in the server not knowing what to do with the output of the script if an error occured. > /dev/null output the errors to never-never land. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.