Last Updated: February 25, 2016
· blazeeboy

Posting image to your tumblr blog using Gmail

well, i'm trying to automate posting my scripts to all by blogs and social profiles, so here is my latest script to send an image with description to tumblr using email posting feature they provide.

#!/usr/bin/env ruby
require 'mail' # gem install mail --no-document

# Credit to : 

def ask question
  print "#{question} ? : "

# get it from : 
# in the Post by Email section
tumblr_email = ''

email = ask('what is your gmail address')

$options = { 
    :address              => "",
  :port                 => 587,
  :domain               => email,
  :user_name            => email,
  :password             => ask('what is your password'),
  :authentication       => 'plain',
  :enable_starttls_auto => true  

Mail.defaults do
  delivery_method :smtp, $options

Mail.deliver do
  from     $options[:user_name]
  to       tumblr_email
  body     ask('write any message associated with the image')
  ARGV.each do |file|
    add_file file

puts 'Posting to tumblr succeeded :)'