-
Website
http://blade.lansmash.com/ -
Original page
http://blade.lansmash.com/2004/08/26/wp-mail-mod-update-now-02/ -
Subscribe
All Comments -
Community
-
Top Commenters
-
smith mountain lake
1 comment · 1 points
-
Loan Modification leads
1 comment · 1 points
-
maietta
1 comment · 1 points
-
kuru
2 comments · 1 points
-
dodly
1 comment · 1 points
-
-
Popular Threads
I guess it's the same as your recommendation for Mozilla Thunderbird and Outlook to just use HTML, so I think I'll be hand-editing for some time.
And one last question: how do I post to other categories?
Thanks for all the work.
I'll try to hack it to make it work and then give you what I used, if I get that far. But, if you do it first, please be so kind as to let me/us know.
Thanks.
//default comment/ping status
$comment_status = get_settings('default_comment_status');
$ping_status = get_settings('default_ping_status');
I also added two lines to the array used for the sql string. It now looks like this:
$details = array(
'post_author' => $poster,
'post_date' => $post_date,
'post_date_gmt' => $post_date_gmt,
'post_content' => $content,
'post_title' => $subject,
'post_modified' => $post_date,
'post_modified_gmt' => $post_date_gmt,
'comment_status' => $comment_status,
'ping_status' => $ping_status,
'post_name' => $post_name
);
However, I am having problems now with it in combination with the plugin called update_notify(). It seems that your code is missing something in it's posting action that triggers the update_notify plugin whereas if I post through the admin UI, the update_notify plugin does work. It may not be your problem, but I just throught I'd mention it.
Again, if I find a solution, I'll let ya know.
So just add a user with a valid email address.
Thanks.
Please feel free to get in touch with me about the changes I have made. Thanks again for the great work!
Is there any solution for that ?
$filename = $photosdir . rand() . '.' . $part->ctype_secondary;
$fp = fopen($filename, 'w');
fwrite($fp, $part->body);
fclose($fp);
$maxdim = 200; // maximum height
$size = getimagesize($filename);
if ((1 < = $size[2]) && ($size[2] <= 3) || ($size[2] == 15)) { // handles JPG, GIF, PNG, and WBMP
if ($size[0] > $size[1]) {
$sizemin[0]=$maxdim;
$sizemin[1]=$maxdim * $size[1] / $size[0];
}
if ($size[1] > $size[0]) {
$sizemin[0] = $maxdim * $size[0] / $size[1];
$sizemin[1] = $maxdim;
}
switch ($size[2]) {
case 1:
$im = @imagecreatefromgif($filename);
break;
case 2:
$im = @imagecreatefromjpeg($filename);
break;
case 3:
$im = @imagecreatefrompng($filename);
break;
case 15:
$im = @imagecreatefromwbmp($filename);
break;
}
$small = imagecreatetruecolor($sizemin[0], $sizemin[1]); // new image
ImageCopyResampled($small, $im, 0, 0, 0, 0, $sizemin[0], $sizemin[1], $size[0], $size[1]);
$small_filename = $photosdir . rand() . '.' . "jpg";
ImageDestroy($im); // free memory
if (ImageJPEG($small,$small_filename,100)) // try to save image
{
echo "File $path has been written
\n"; // success
echo "size: ".$sizemin[0]."x".$sizemin[1] ."
\n";
}
else
{
echo "<font color="red">"; // failed to write file
echo "Error ! File has not been written.";
echo "</font>
\n";
}
$meta_return .= '<a target="_blank" href="' . $filename . '" onclick="popUp('viewer.php?image='.$filename.'','Image Viewer',' . round($size[0],0) . ',' . round($size[1],0) . '); return false;"><img src="' . $small_filename . '" alt="' . $part->ctype_parameters['name'] . '">ctype_parameters['name'] . '"></img>' . "\n";
}
else
{
$meta_return .= '"<img src="' . $filename . '" alt="' . $part->ctype_parameters['name'] . '">ctype_parameters['name'] . '"/>' . "\n";
}
break;
< /></img>
You also need to add this javascript code to index.php:
popUp(sURL,sName,iWidth,iHeight) {
window.open(sURL,sName,'width='+iWidth+',height='+iHeight+',scrollbars=no,noresize');
}
if ((1 $size[1]) {
how do I insert the script in index.php?
thanks to hugo! most of the problems occured because of the formating done by wordpress in the comments, so I have posted my working version here .
at next I want to find out how to get the german letters like ä working...
Warning: Invalid argument supplied for foreach() in /public_html/blog/wp-includes/template-functions-category.php on line 70
Only happens when attaching pictures. Emailing a regular post works just fine. I can live with this, but was just curious.
Again - thanks for all your hard work!
Im new to wordpress, so could this be a problem with my wordpress settings?
//Author: J. Otis Riggins; otis@gnbi.com
//Use as you like!
//What does it do? It creates a smaller .jpg image scaled to your specs while maintaining the aspect ratio of
//the original image. The function was created to support image uploading using wp-mail for users who upload
//large images but could be used for other image scaling task as well.
//
//By replacing a line in the wp-mail.php file and adding the function to the end of wp-mail.php it will cause
//the thumbnail image to be displayed in the blog message and linked so that when a user clicks on it the larger
//original image will be displayed in a seperate window. The method I chose was to append "tn_" to the begining
//of the image name and saving both files into the wp-photos directory.
//
//To use replace the following line in wp-mail.php with the five lines after it and include the function in wp-mail.php
$meta_return .= '<img src="' . $filename . '" alt="' . $part->ctype_parameters['name'] . '">ctype_parameters['name'] . '"/>' . "\n";
$thumb = dirname($filename) . "/tn_" . basename($filename);//append "tn_" to begining of filename for thumbnail
$pos = strrpos($thumb, ".");
$thumbfile = substr($thumb, 0, $pos + 1) . "jpg";
$strsize = sizeit($filename, $thumbfile, 400, 300);// Adjust width & Height to suit I like 400X300
$meta_return .= '</img><img src="' . $thumbfile . '" alt="' . $part->ctype_parameters['name'] . '">ctype_parameters['name'] . '" ' . $strsize . ' border="0"/>' . "\n";
function sizeit($filename, $thumbfile, $maxwidth, $maxheight) {
set_time_limit(1000);// just to be safe
$array = GetImageSize($filename);
switch ($array[2]) {
case 1:
$im = @imagecreatefromgif($filename);
break;
case 2:
$im = @imagecreatefromjpeg($filename);
break;
case 3:
$im = @imagecreatefrompng($filename);
break;
case 15:
$im = @imagecreatefromwbmp($filename);
break;
}
$cwidth = $array[0];
$cheight = $array[1];
if ($cwidth > $maxwidth) {
$pdivisor = $maxwidth / $array[0];
$cwidth = round($array[0] * $pdivisor);
$cheight = round($array[1] * $pdivisor);
};
if ($cheight > $maxheight) {
$pdivisor = $maxheight / $cheight;
$cwidth = round($cwidth * $pdivisor);
$cheight = round($cheight * $pdivisor);
};
$resize = imagecreatetruecolor($cwidth, $cheight); // Create a blank image of the propersize
imagecopyresampled($resize, $im, 0, 0, 0, 0, $cwidth, $cheight, $array[0], $array[1]); // Resample the original JPEG
imagejpeg($resize, $thumbfile, 100);// save the thumbnail file - quality set here to 100% which is max
$picsize = 'width="' . $cwidth . '" height="' . $cheight . '"';
imagedestroy($im);// to free memory
imagedestroy($resize);// to free memory
return $picsize;// return the new thumbnail pic size formatted for image tag
}</img>
Since I know going to http://<website>/<wp blog="blog">/wp-email.php will process any waiting emails, Since the script outputs the post to the web browser as it makes the post, I could attempt to run it on sites not my own and read their incoming posts regardless of the security level (if using viewlevel plugins, etc).</wp></website>
However, I have two issues:
1 - it won't delete the e-mail from the server, resulting on posting the same thing over and over;
2 - it is conflicting with my Show Categories plugin:
Warning: Invalid argument supplied for foreach() in /home/mgateco/public_html/maneblog/wp-includes/template-functions-category.php on line 9 (displayed at the Posts tab of the WordPress admin page, and
Warning: Invalid argument supplied for foreach() in /home/mgateco/public_html/maneblog/wp-content/plugins/showcategories.php on line 254, displayed at the front page of my blog.
What can I do to fix this?
Yours,
oculos
Thanks a lot for this nice hack! I like it! But one question, is there a solution how to handle the raw html code output? I saw here in the comments more questions and ih have the problem too. Has anyone got that working with HTML-Emails?
Thank you John for these hack!
Sebastian
Very useful utility.
So, I added the functionality to the wp-mail.php file.
Modifications to John B. Hewitt's hacked wp-mail.php version 2.0 - http://blade.lansmash.com/index.php?cat=5
Adds coordinate parsing, which according to the wiki was working at some point.
I borrowed the coordinate parsing from http://drbacchus.com/wordpress/index.php?p=631
This hack extracts the first set of coordinates from the body of the email and inserts them into the database
Coordinates must be in the format: 33d39.452,-117d42.315
That's "Degrees" then "d" then "Minutes" then "." then "Minutes"
Note that the last is in minutes, not seconds.
Coordinates can be anyplace in the message body.
Comments and improvements welcome.
Brad Wilson - bwilson@b-photo.com
After this:-----------------------------------------------------------------
//date reformating
$post_date = date('Y-m-d H:i:s', time($ddate) + ($time_difference * 3600));
$post_date_gmt = gmdate('Y-m-d H:i:s', time($ddate) );
Add this:-----------------------------------------------------------------
//get Latitude
$latitude = getLat($content);
//get Longitude
$longitude = getLon($content);
After this:-----------------------------------------------------------------
print 'Subject: ' . $subject . '
' . "\n";
Add this:-----------------------------------------------------------------
print 'Coordinates: ' . $latitude . 'x' . $longitude . '
' . "\n";
After this:-----------------------------------------------------------------
'post_title' => $subject,
Add this:-----------------------------------------------------------------
'post_lat' => $latitude,
'post_lon' => $longitude,
After this:-----------------------------------------------------------------
function charsetcheck ( $part )
{
if ( strtolower($part->ctype_parameters['charset'] == 'utf-8') )
{
$part->body = utf8_decode($part->body);
}
return $part;
}
Add this:-----------------------------------------------------------------
/**
* Grab Latitude from message body
* Coordinates must be in the form: 34d13.345,-123d45.234
* That's degrees, then 'd' and then minutes.minutes
*/
function getLat ( $data )
{
$coords = '((-?)(\d+)d(\d+\.\d+)),((-?)(\d+)d(\d+\.\d+))';
preg_match("/$coords/mx",$data,$matches);
//$lat=$matches[1];
/* Convert to Decimal */
$latd = $matches[3];
$latm = $matches[4];
$lat_sign = $matches[2];
$lat_dec = $latd + $latm / 60;
$lat_dec = $lat_sign . $lat_dec;
return $lat_dec;
}
/**
* Grab Longitude from message body
* Coordinates must be in the form: 34d13.345,-123d45.234
* That's degrees, then 'd' and then minutes.minutes
*/
function getLon ( $data )
{
$coords = '((-?)(\d+)d(\d+\.\d+)),((-?)(\d+)d(\d+\.\d+))';
preg_match("/$coords/mx",$data,$matches);
//$lon=$matches[5];
/* Convert to Decimal */
$lond = $matches[7];
$lonm = $matches[8];
$lon_sign = $matches[6];
$lon_dec = $lond + $lonm / 60;
$lon_dec = $lon_sign . $lon_dec;
return $lon_dec;
}
ok--> essai sans image
ok--> cat 2
but i have this displayed also. How can i do for remove this?
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv='3D"Content-Type"' content='3D"text/html;'>
<title>Message</title>
</meta><meta content='3D"MSHTML'></meta></head>
<body>rial size=3D2><span class="3D826471507-31102004">essai =
sans=20
image</span>
<div><font face="3DArial" size="3D2"><span class="3D826471507-31102004">cat=20
2</span></font></div></body></html>
essai sans image
cat 2
< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html><head>
<meta http-equiv='3D"Content-Type"' content='3D"text/html;'>
<title>Message</title>
</meta><meta content='3D"MSHTML'></meta></head>
<body>rial size=3D2><span class="3D826471507-31102004">essai =
sans=20
image</span>
<div><font face="3DArial" size="3D2"><span class="3D826471507-31102004">cat=20
2</span></font></div></body></html>
because i can't display code here. sorry for my multi posts!
It seems the solution is:
# Send email as text
# Any images attached to that email
# If you need to embed HTML codes, then make sure that line 193 is as follows:
$meta_return = $part->body;
(instead of filtered by htmlentities)
Hope it helps.
-Brian
I have tried both the Hugo... Mudhen download
and the Otis hack
With the mudhen download the thumbnail never gets dumped into the wp-photos folder and so it never shows up,
the otis hack gives me a parce error ";" unexpected at 204 and I cant seem to figure it out.
It sounds like its working for some...anyone have a hacked and working wp-mail that they could email my way.
My wife would most appreciate it LOL
Thanks
Cryptik
I just doenst want to write the thumbnail.
Thanks
Cryptik
iamgecreatetrue to imagecreate and
imagecopyresampled to imagecopyresized
works perfect now... GREAT HACKS YOU GUYS keep them coming!!!
I get a cron error when running
ERROR:
/home/mysite/public_html/wp-mail.php: line 1: ?php: No such file or directory
/home/mysite/public_html/wp-mail.php: line 3: /aquota.user: Permission denied
/home/mysite/public_html/wp-mail.php: line 4: etc: command not found
/home/mysite/public_html/wp-mail.php: line 5: etc: command not found
/home/mysite/public_html/wp-mail.php: line 6: syntax error near unexpected token `('
/home/mysite/public_html/wp-mail.php: line 6: `* Copyright (c) 2003-2004 The Wordpress Team'
if i open the file in the browser it will post.
UH?
any help would be super, i just upgraded from MT.
I love this hack. My PHP skills are sucky-sucky-5-dollah so I'm glad you're sharing this with us...
One thing though:
Immediate features to come:
- Direct email script that parses email as it comes in (so removes cronjobs)
Any idea when you will have this going? Thanks!!!
I have set up the emailing properly. However, I have found that when I post, there is no actual post slug or file name. So, the links on the blog are /24/11/2004// for example ... instead of /24/11/2004/post-name-here.
Posting regularly is fine, however this is a problem only when posing by email. I have tested it multiple times, even using the hack from the wiki (new wp-mail).
Any suggestions?
It does seem to check the mailbox, but it fails to see the emails that I know are there. (I checked the mailbox with mail syphon for OSX.) Any advice would be muchly appreciated. Thanks!
$details = array(
'post_author' => $poster,
'post_date' => $post_date,
'post_date_gmt' => $post_date_gmt,
'post_content' => $content,
'post_title' => $subject,
'post_modified' => $post_date,
'post_modified_gmt' => $post_date_gmt
);
and change it by adding the post_name field:
$details = array(
'post_author' => $poster,
'post_date' => $post_date,
'post_date_gmt' => $post_date_gmt,
'post_content' => $content,
'post_title' => $subject,
'post_modified' => $post_date,
'post_modified_gmt' => $post_date_gmt,
'post_name' => sanitize($subject)
);
Tested and seems to work.
Allan
texas holdem here :) right free
online texas holdem here. But right away here
http://www.texas-holdem-p.com you can find the right info for play texas holdem
now.
online poker here :) right free
online poker here. But right away here
http://www.online-poker-888.us you can find the right info for play online poker
now.
cronjob to process the email, any posts that get processed appear at the time thecronjob runs, not when they were actually submitted.To fix this, change the following two lines:
$post_date = date('Y-m-d H:i:s', time($ddate) + ($time_difference * 3600));$post_date_gmt = gmdate('Y-m-d H:i:s', time($ddate) );
to (changes in bold):
$post_date = date('Y-m-d H:i:s', strtotime($ddate) + ($time_difference * 3600));$post_date_gmt = gmdate('Y-m-d H:i:s', strtotime($ddate) );
Enjoy!
Just change the call to the "time" function to "strtotime" instead.
After this code...
if (empty($post_categories))
$post_categories[] = get_settings('default_category');
Add this code:
// creates a variable to be used as the post's slug
$array_post_name = explode(" ", strtolower($subject));
$string_post_name = implode("-", $array_post_name);
Then add a line to your $details array like this:
$details = array(
'post_author' => $poster,
'post_date' => $post_date,
'post_date_gmt' => $post_date_gmt,
'post_content' => $content,
'post_title' => $subject,
'post_modified' => $post_date,
'post_modified_gmt' => $post_date_gmt,
'post_name' => $string_post_name
);
I also hacked mine to use the free Audioblogger system with Wordpress. It's pretty easy, since you can get Audioblogger to send an HTML formatted email to a specified address whenever you post. Then you just write a function to strip out some of the code from that email. If anyone wants me to post a tutorial here or on my site, I will.
Thanks for this cool hack. I love using it with cell phone photos too.
recommen this website online poker . Please refer to our
friends and play online poker also free
online poker http://www.online-poker-888.us to our best greetings.
recommen this website online poker . Please refer to our
friends and play online poker also free
online poker http://www.online-poker-888.us to our best greetings.
I have tried the strto fix, but didn't know where to "just change the call to the 'time' function to 'strtotime' instead".
For everyone running PHP5 (Han's, etc) wp-mail ver 0.2 won't work. This is because of a problem with Pear's mimedecode objective stuff being messed up. I've fixed it and submitted the bugs to Pear, so basically it's fixed in wp-mail ver 0.3.
I'm just testing 0.3 now and if it passes by the end of the week I'll post it up. Stay tuned...
...
Just modify $time_difference * 3600 in:
$post_date = date('Y-m-d H:i:s', time($ddate) + ($time_difference * 3600));
$post_date_gmt = gmdate('Y-m-d H:i:s', time($ddate) );
Change the numbers to match the timeserver of your cron job. It'll be different for each server.
Sent out using PLAIN text. Tried to modify with the suggestions given above for HTML, but it still did not turn out well. Plus, if I posted with picture in HTML via email, I'll still get the error thing about the $post_categories.
Mobile-blogging OK. Just make sure you have your mobile-email stored as an email under users in wp inself to work. Formatting still lacking though (sadly).
Otherwise, I'll say this works just fine for me! :D
- Tons of interesdting stuff!!!
Any Ideas?
Cryptik
I am keen to hear if somebody has some idea's or working hacks!