Search interesting materials

Sunday, March 04, 2007

How to make email to blogger work

One of the neat features of blogspot used to be submission of blog postings by email. Email->blogger is highly convenient for me, particularly because I write most of my blog postings when offline. When I moved to the the new software release in January 2007, this feature stopped working. The interactive authoring component that blogspot has is inconvenient and buggy.

With a little help from my friends, I figured out how to do email to blogger. To the best of my knowledge, this information isn't yet on the net, so here goes.

The key insight is that the email that must be submitted to blogger must have content type text/html and must have only one object in it (the HTML content). There must be no attachments or anything else.

Generic receipe using sendmail

This works as long as you have a machine with a working MTA. Regardless of what your MTA is, generally there is an executable named "sendmail" where many flags of sendmail are respected.

First make a file named `posting' as follows:


To: myblogemailaddress
From: ajayshah@mayin.org
Subject: Title of posting
Content-Type: text/html

<html>
<body>
Content of posting.
</body>
</html>

Send this off by saying:

 $ cat posting | sendmail -i -t 

Incantations specific to one MUA - mutt

Make an HTML file posting.html starting with until . Bring it into the text of the email using mutt by saying:

 $ mutt -i posting.html myblogemailaddress 

This puts you into an interactive editor screen. Fill in the title of the post under `Subject:' and exit the editor.

Now you will face the mutt menu screen. There is no attachment, there is only an email that you've been writing `by hand'. Say Ctrl-T to change from text/plain to text/html and send.

Weaknesses

I haven't figured out how to place labels into the HTML that's submitted. As a consequence, I go into the blogspot interactive screen to tag the posting with labels. That's tedious, and further, blogspot emits one more entry into the RSS feed when the labels are added or modified.

5 comments:

  1. Hi,

    Have a look here.

    http://tooh.blogspot.com/2007/04/blogger-delicious-hack.html

    I managed to post my del.icio.us links to Blogger. It seemed that mailing them was one of the solutions. My Perl script is using a mail sender package that I configured for HTML mail. Voila. Just like you I'm missing a way to add labels in the mail. Flickr has a syntax of mixing tag:anylabel in the subject or in the body. I will look further if Blogger has any support for labels in the mail. Otherwise this could be a enhancement request for Blogger.

    ReplyDelete
  2. Hi!

    I am using an SMTP Relay to send messages via an ASP script to Blogger blog. But I cant find a way to publish images by that.

    I use an HTML type posting with images embedded via src=cid: in my HTML post, but the images dont appear.

    I however found that....Invite friend option on www3.phonerotica.com sends the embeded images successfully via email and those posting appear properly in BLOG.

    Do you know or let me know ... what modifications in my HTML or Script[Any PHP or ASP] do I need to do to either embed or attach the file that it automatically gets saved and displayed on blog..via blogger server.

    I tried src=cid method but that appears to fail.

    Pls help n reply me in plain txt only without attachments.

    Awaiting your repsonse
    Niki
    tandon1.nikita@Blogger.com

    ReplyDelete
  3. um. I'm also doing 'cid'
    I embeded my pictures into the e-mail with thunderbird, and when it sent it seemed to attach the image as:
    <img src="cid:part1.06030708.03070203@gmail.com" height="300" width="400">

    Which is a bad address.
    Normally when I simply attach the pictures it works fine. Apparently this 'cid' thing didn't work with blogger?

    ReplyDelete
  4. @isaaclw , may be the author doesnt want to reply at all.

    However, it seems cid does not work but instead attaching the image with a line in body of message in script works for posting, where msg comes afterwards.

    However, phonerotica thing works, try sending an invite mail from phonerotica wap site and it gets posted to your blog via blog to email address in a well fashioned manner and with embedded images, not using cid but images do get saved to blogger account automatcially.

    I dont know how is this happening

    Now,
    tandon1.nikisa [at] blogger.com
    Pls Reply ASAP.

    ReplyDelete
  5. Hi

    CID does not work because mutt does not create Content-ID header when attaching images.

    But there can be work around adding Content-ID header during some postfiltering action. For example I use script callback calling mutt like this (bash/shell script case):

    mutt -e "set content_type=text/html" -e "set sendmail=\"$0 sendmail\"" (...)

    and at the begining of the script there is postfilter part:

    if [[ $1 == 'sendmail' ]]
    then
    sedReg='\(Content-Disposition: attachment; filename="\)\([^"]\+\)\(.*\)'
    sedOut='\1\2\3\nContent-ID: <\2>'

    sed "s/${sedReg}/${sedOut}/" |
    /usr/sbin/sendmail -oem -oi ${@#sendmail*}

    exit
    fi


    Use unique image name as it is possible because Content-ID made here from image name should be unique. For example adding such suffix to image: $(date +%s.%N).

    ReplyDelete

Please note: Comments are moderated. Only civilised conversation is permitted on this blog. Criticism is perfectly okay; uncivilised language is not. We delete any comment which is spam, has personal attacks against anyone, or uses foul language. We delete any comment which does not contribute to the intellectual discussion about the blog article in question.

LaTeX mathematics works. This means that if you want to say $10 you have to say \$10.