Let’s say you wish to use the WordPress function for blogging via email posts. This work great for HTML emails in Yahoo Mail. It works great for Google’s Gmail in plain-text format. How about Gmail in HTML emails? Things get trickier. That’s why I present you my very first PHP small add-on.What ca you read in this blog post?
1. What does my software do?
2. What does my software doesn’t do?
3. How can you personalize the blog to work only for your email address?
4. What should you note?
5. Ok, ok, where’s the software? Download link?
6. How do you know it works?
Ok, now you know it. Let’s get going.

1. What does my software do?
My PHP add-on does one single trick: helps you put HTML emails. It works great with Gmail (tested it a lot on some of my blogs, see the end of this blog post), and it works not-so-bad with Yahoo! Mail (only done a few tests, though).
It also try to fix a bug of WordPress for breaking posts that contain Unicode characters.

2. What does my software doesn’t do?
Unicode characters are a big pain for WordPress. There are some characters which are poorly converted. This problem is also common for sending emails. What’s the solution? I’ll present my case story: whenever I send an email that has Unicode characters, I first try to convert those Unicode characters into ASCII. This can be solved quite easily in Notepad (under Windows Operating System). Just create a blank document in Notepad, put the Unicode text in there. Save it. Notepad usually warns you that if you want don’t save as Unicode, you’ll lose some formatting. Hit Ok, then reopen the document. Most Unicode texts are gone. There are still some problems (quotes, for example, are not converted) and for those … I’ve created a different software. See the blog post in here.

3. How can you personalize the blog to work only for your email address?
You can replace this line:
if (( is_email($author) ) && ($author == ‘PUTYOUREMAILADDRESSINHERE@SOMEMAIL.COM’)) {

with this line:
if ( is_email($author) ) {

Also, replace these two lines:
        // Author not found in DB, set status to pending.  Author already set to admin.
$post_status = ‘publish’;

with these two lines:
        // Author not found in DB, set status to pending.  Author already set to admin.
$post_status = ‘pending’;

Finally, replace these three lines:
                    if (!$userdata) {
$post_author = 1;
$author_found = false;

with these three lines:
                    if (!$userdata) {
$post_author = 1;
$author_found = true;

4. What should you note?
I am not responsible for errors you might encounter with your software. You can leave a comment below and explain your errors, and I’ll see what I can do, you can post your errors on WordPress’s support page or search its archives. Please note that this is my very first software in PHP and I’ve learned the commands mostly by trial and error.

5. Ok, ok, where’s the software? Download link?
You can download my software in here:
wp-mail.php made by Olivian BREDA. Use at your own risk

Use it at your own risk.

6. How do you know it works?
Well, I’ve tested it for a few months now. These are the blogs where I’ve tested my software:


28 Responses to “WordPress: How to use wp-mail.php correctly in Gmail blog posts? This is my solution”  

  1. 1 Refr

    Great Hack! I used your code to post my very first Post Via Emails! Many Many Many Thanks!

  2. 2 Olivian BREDA

    I’m so glad you like it. :)

    You’re the very first person confirming it works. :d/

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  3. 3 Salvatore

    [quote]Plugin Installed

    However, I couldn’t verify that it really is a plugin. Hmm.[/quote]

    and I can’t find it in plugin panel :(

    Salvatore’s last blog post..Finalmente in vendita, su eBay, il Bosone di Higgs

  4. 4 Olivian BREDA

    Hello Salvatore, you should try to replace your wp-mail.php file in your FTP folder with my own. I didn’t make a plug-in, it’s just a new PHP file.

    You then run it by typing this in the address bar:
    [name of your blog]/wp-mail.php
    and hit Enter.

    Does this solve the problem?

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  5. 5 AL Geddis

    I just uploaded your wp-mail.php file to my site. I then went to www.mysite.com/blog/wp-mail.php and got this message: POP3 connect: Error [97] [Address family not supported by protocol]

    I also do not understand how this would work-I want to be able to send a post via my gmail account, but to WHERE would I send it?

  6. 6 Olivian BREDA

    Hello AL Geddis,

    Thanks for the comment.

    1. Could you please try the original wp-mail.php, the one provided by WordPress and tell me the error you get? I can then find out if the error is in my software or in your configuration;

    2. You must configure an email address on your server on which to send emails to;
    so if your site is greatsite.com, you’ll have to have an address like myemail@greatsite.com. You can configure this address in the Settings area (or Options for older versions of WordPress); Then go to Writing Tab and voila. At the end of the page you’ll find these settings;

    You can read all about it here:
    http://codex.wordpress.org/Blog_by_Email

    If you wish, you can let us know how’s it going. :">

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  7. 7 Souvik Banerjee

    I am still getting this error!!!

    Hey! Welcome to my optimized-for-Yahoo-and-Gmail interface.

    I’ve read the following encoding before actually reading the email (to evoid gmail errors):7bit

    I’ve read the following encoding before actually reading the email (to evoid gmail errors):7bit

    Gmail address found. Setting specific settings.

    Yahoo address NOT found. Going to normal email settings.
    Author of the blog post = ghajinii2008@gmail.com

    Author: 1

    Posted title: Test

    Mission complete, message 1 deleted.

    You can always check out my web site for more IT tricks: http://getaresultnow.com/:(:(

    Souvik Banerjee’s last blog post..Movie Poster

  8. 8 Olivian BREDA

    There are some problems with emails that contain:
    1. Images;
    2. Special characters;

    Try posting different types of emails.

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  9. 9 moleboy

    THANK YOU! I work for the government and so I can’t really blog anythiung political from work, but with email, I feel OK doing it. Now that I can easily get HTML in there, I’m excited!!

    SOmething else that would be nice: being able to assign categories through email. Right now, there’s just the default email category, but if I could select more…

    just a thought if you are feeling like writing up other enhancements ;)

    thanks again!!

    moleboy’s last blog post..Huckabee: Prop 8 doesn’t ban gay marriage

  10. 10 Olivian BREDA

    I’ve got such a proposal via email and I’m working on it right now. :D

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  11. 11 moleboy

    You da man ;)
    (someday I’ll get off my butt and learn php)

    moleboy’s last blog post..Huckabee: Prop 8 doesn’t ban gay marriage

  12. 12 Olivian BREDA

    Thanks, when I’m done making it, I’ll post the update in this blog post. :D

    Olivian BREDA’s last blog post..Botnets – first understand them and then fight them. A practical guide

  13. 13 David Stembridge

    This is working for me, however in step 3:
    if (( is_email($author) ) && ($author == ‘PUTYOUREMAILADDRESSINHERE@SOMEMAIL.COM’)) {

    with this line:
    if ( is_email($author) ) {

    I get an error…
    Parse error: syntax error, unexpected ‘@’ in /homepages/4_/d_________/htdocs/samburu/blog/wp-mail.php on line 112

    any suggestions? I changed it back to default, and by golly, it is working! I would like to have only one sender email address set though.
    Thanks!

  14. 14 Olivian BREDA

    There’s something wrong. If you replace the strings as said, there is no more a ‘@’ sign.

    Please open the wp-mail.php in a text editor and go to line 112 and provide me with that line.

    Thanks.

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  15. 15 David Stembridge

    ok, I may have had it backwards… Currently, line 112 has:

    if ( is_email($author) ) {

    I was thinking I had to change it to:
    if (( is_email($author) ) && ($author == ‘PUTYOUREMAILADDRESSINHERE@SOMEMAIL.COM’)) {
    adding my sending email address.

    Are the posts supposed to post automatically, or do I have to install WP-Cron? I noticed they show up after running wp-mail.php from my url window…

    Thanks! David

  16. 16 Olivian BREDA

    This line works perfectly for me:
    if (( is_email($author) ) && ($author == ‘mymail@gmail.com’)) {

    I can’t figure it out.

    You have to instal WP-Cron or a similar feature.

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  17. 17 David Stembridge

    all right, I did install WP-Cron, that is working now,
    I did change the line to:

    if (( is_email($author) ) && ($author == ‘myaccountname@gmail.com’)) {

    and get this error still:
    Parse error: syntax error, unexpected ‘@’ in /homepages/40/d_________/htdocs/samburu/blog/wp-mail.php on line 112

    very odd!

  18. 18 Olivian BREDA

    I’ll look into it when changing for a new version. Don’t know what causes the problem. :(

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  19. 19 David Stembridge

    I tried just tried removing the “@gmail.com”
    leaving only my username on line 112
    and it seems to be working now.

    Well… I just did 2 tests, and they are listed in posts as pending. I will check my cron settings. What alternative to wp-cron can you suggest?

    Thanks again!

  20. 20 Olivian BREDA

    I’m glad it worked for you.

    Regarding Cron: This is what I personally use:
    http://activeblogging.com/info/wordpress-cron-plugin/

    Basically, whenever a user visits my blog, it runs the function. If 15 minutes (or whatever) passed since I last run the code, then the code is executed (run wp-mail.php). I use more than one blog and all of them have this function.

    It’s less bother to me than do a WP-Cron server side. :)

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  21. 21 David Stembridge

    Hey Olivian, I tried the plugin you mentioned above, it hasn’t started working yet. what do you set you “time” (00:00) for?

    Looks like everything else is working great. Thanks again, David

  22. 22 Olivian BREDA

    my settings are like this:
    1. an hour to start like 17:30 (you can also put 00:10)
    2. 15m
    3. http://fiieficient.com/conferinte/wp-mail.php

    You should also check out this thing:
    Your theme MUST have the function wp_footer included in it, like this:
    < ?php wp_footer(); ?>

    (most newer themes already have this in footer.php or possibly index.php).

    So: put it to 10 minutes.

    After 12 minutes pass, visit your blog.

    After you visit your blog, visit it once again.

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  23. 23 Olivian BREDA

    @moleboy: for now I can’t make categories work. More research required, but no solution for now. :(

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  24. 24 moleboy

    Yeah, I think that’s been something a lot of people have tried and not been able to do.
    Oh well.
    I was actually trying to fake my way through to get it to handle posts emailed from Google Reader better. But, not knowing anything about php made that rather difficult. I might take another whack at it at some point…just to get it to maybe strip out the graphics or, at the very least, the signature that this came from google reader, etc.

    moleboy’s last blog post..Daily Kitteh!

  25. 25 Olivian BREDA

    Sorry, I’m also at very beginning of PHP. :(

    Olivian BREDA’s last blog post..Why vote? The one reason for which anyone should vote. Read this message, and then go voting!

  1. 1 links for 2008-10-01 « Schedelbeuk
  2. 2 How to Posting Blog From Email to Wordpress | VR Junkyard - Articles, Tips, Downloads, Infos, and lots more
  3. 3 ~daily random journal of the netholic vierz~ » Cara posting blog ke wordpress dari email dan blackberry

Leave a Reply. Please post in English only, no other languages. Thanks.

:) :( :d :"> :(( \:d/ :x 8-| /:) :o :-? :-" :-w ;) [-( :)>- more »