Configuring Mutt for Gandi Mail (IMAP and SMTP)

Gandi is my favorite registrar for many reasons. Their motto is “No Bullshit” and they mean it. They make it super easy to manage domains, and offer tons of great services. One of the best things about buying a domain from Gandi is that they provide you with free email for the life of your domain. Setting up a mail server can be a pain in the ass, so this is really kind of awesome.

mutt is an awesome MUA (Mail User Agent) that is light weight, terminal based, and highly customizable. Your local mail system can be as complex or as simple as you want it to be. There are countless guides out there on how to mutt, but a lot of them seem way to complex for my use case and can get very confusing.

This guide will help you get mutt working with Gandi mail. Gandi mail is a pretty generic mail stack so this should also apply to any other IMAP/SMTP mail system that uses Dovecot, Postfix, etc… as well.

My use case is this:

  1. I use Gandi mail for all of my personal email for a single address.
  2. I want to connect to Gandi using IMAP with mutt
  3. I want to send mail with mutt by connecting to Gandi with SMTP

Note that there are no local folders on my machine in this use case, so everything is happening on the mail server. A lot of the mutt guides assume that you are using mutt for just reading email and are using some external program like fetchmail to receive the mail to a local folder, and some external smtp system like msmtp to send it. This is not what we are doing here, so if you want this type of setup I would suggest looking at this guide instead.

With this simple use case in mind, your .muttrc file becomes super simple.

  1. If you have not already, install mutt.
    #On Debian Based Distros 
    apt-get install mutt 
    
    #On Red Hat Based Distros 
    yum install mutt 
    
    #On Mac OS X, assuming you have Homebrew Installed
    brew install mutt 
    
  2. Open up a text editor and put the following in your ~/.muttrc file
    # Configure imap username and password 
    set imap_user="[email protected]"
    set imap_pass="YourPassword"
    
    # Configure Default Folder and where to put Sent Mail 
    set folder="imaps://mail.gandi.net:993/"
    set spoolfile=$folder
    set record="=Sent"
    
    # Configure SMTP Settings 
    set smtp_url = "smtp://$imap_user:[email protected]:587/"
    set realname="Your Name"
    set from="[email protected]"
    set use_from = yes
    
    # Enable STARTTLS for Security
    set ssl_starttls=yes
    
  3. Fire up mutt, you will be logged into your Gandi inbox and you can start rocking out your mail.

This was a super simple config and it “just works”. It allows you to perform the basic functions of receiving, reading, and sending mail. You can now go read about the other 10,000 config options in the mutt manual.

UPDATE 1

Added STARTTLS to .muttrc example, thanks to Kenn for the catch.

Hacking an Angular.JS game for Fun and (fake) Profit

Last night I came across an interesting game called Giant Shaft Enterprises. In this game you play the role of a CEO of a fictitious company and the goal is to maximize your profits and reduce costs. You do this by performing business opportunities such as “Network with business leaders”, “Push the envelope”, and “Streamline workforce”. You also can hire employees, purchase buildings, establish various departments, and motivate your workforce with seasoned upper managers. The last thing that you can do in the game is purchase upgrades such as health benefits, electric car charging ports or allow upper managers to hold useless meetings. These upgrades maximize the performance of your workforce. All of these things make more money for your company and allow you to get achievements.

This is pretty much like any other point, click, and wait game that you would find in the “Top 10 Free Games” section in an App store, but the difference is that this game does not take any real money from you.

The game is very entertaining and kind of trolls the world. For example, buying more cubicles for your company provides a higher ROI than hiring additional upper managers. The game is also strangely addictive, I found myself clicking on the same button thousands of times to get more money and increase the profitability of my company. I must have played for a few hours before I began filling a bit silly for wasting my time clicking on a button. A few hours later not only was I feeling silly I was also beginning to get an repetitive stress injury in my wrist.

That is when I realized that clicking on the button to watch my company sore to greatness was not providing me with the highest ROI. Then I decided to streamline my efforts and opened up the Chrome Javascript Console to see if I could outsource me clicking this button to a simple Javascript program.

Luckily, this was pretty straightforward. The app is written in Angluar.JS and all of the various buttons that you click to do things are exposed in the DOM. Using JQuery you can access these buttons a simulate a click through the Javascript console that can be found in the Developer Tools of most browsers.

For example, the button that lets you take advantage of business opportunities (and instantly raise more money) calls a function called doBusiness. You can select it, and send it a click() like this:

$('div[ng-click="doBusiness(opportunity, $event)"]').click();

You can also send it 10, 100, or 1000 clicks by wrapping this in a loop.

for ( i=0; i < 100; i++ ) { $('div[ng-click="doBusiness(opportunity, $event)"]').click(); } 

All of the things that you buy in the game use the same function called buyStoreItem, but the individual items (such as employees, cubicles, and harware) are referenced by index. Using the similar method you can purchase things in various multiples by wrapping the function in a for loop like so:

# Buy Cubicle 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[1].click(); } 

I found that if I try to send more than 1000 clicks at once, the app tends to freeze and bomb out. Looking in htop, chrome is using up 100% of my CPU so it looks like 1000 is the magic number. Javascript is fast and it looks like it sends all 1000 clicks pretty much at once which confuses the app and makes it very sad. I realize this goes against the spirit of the game, but nonetheless it was a fun little exercise and games should reward cleverness.

A full list of Cheats Synergistic ROI Optimizers is listed below:

# Giant Shaft Cheats 

The lines below simulate clicks, to run then open up the Javascript Console (in Chrome this is Ctrl+Shift+i) and enter them. To change the amount of simulated clicks change the second value in the for loop ( i < 100 ) to something other than 100. Going above 1,000 will probably crash the app :) 

# Do Business Opportunities 

for ( i=0; i < 100; i++ ) { $('div[ng-click="doBusiness(opportunity, $event)"]').click(); }  

# Buy Minium Wage Worker 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[0].click(); } 

# Buy Cubicle 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[1].click(); } 

# Buy Salary Employee 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[2].click(); } 

# Buy Hardware 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[3].click(); } 

# Buy HR Department 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[4].click(); } 

# Buy Accounting Department 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[5].click(); } 

# Buy Benefits Package 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[6].click(); } 

# Buy (Useless) Upper Management 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[7].click(); } 

# Buy Executive 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[8].click(); } 

# Buy Office Building 

for ( i=0; i < 100; i++ ) { $('div[ng-click="buyStoreItem($event, item)"]')[9].click(); } 

Thanks to this little hack I am the king of Giant Shaft Enterprises. Thank you to Eric Freeman for making this awesome game!

**UPDATE 1: **

I was curious to see what the max number of clicks I could pass through was. I enabled logging to show me when the loop made the 100th click.

for ( i=0; i < 1000; i++ ) { $('div[ng-click="doBusiness(opportunity, $event)"]').click(); if (i % 100 == 0 ) {console.log('Click #' + i)}}

It looks like the app actually does not crash … but becomes super slow after about 3000 clicks. So to optimize ROI you should only cheat with around 1000 fake clicks at a time.

**UPDATE 2: **

The final step of this was obviously to automate the automated clicks. Using Javascripts setInterval method, we can have the script run indefinitely. For example the following code, does 100 business opportunities every 3 seconds, forever.

setInterval(function() {for ( i=0; i < 100; i++ ) { $('div[ng-click="doBusiness(opportunity, $event)"]').click(); if (i % 10 == 0 ) {console.log('Click #' + i)}}}, 3000);

ezBadge v2: Now in Stunning Javascript HD

If you have ever wondered what it looked like to convert an application from Python to Javascript, you are in luck. After finishing ezbadge yesterday, I came to the realization that the entire thing could and should have been written in Javascript. There is absolutely no reason for this thing to send any requests to a server in order to process the URL and render the markdown.

So, I did just that. Introducing, ezBadge v2

Screen Shot of EZ Badge
Screen Shot of EZ Badge

After removing all of the Flask, I was able to create two Javascript functions that essentially did the same thing as the Flask app was doing for me.  The added benefit is that other than serving the initial HTTP request, I do not have to handle any additional requests and the entire thing now runs in the browser.

This was a fun little exercise, and I think the Javascript version of this application is a bit more elegant. Rather than appending the template with Jinja as I was doing before, I am now spawning a modal (after doing some for

m validation) and then using the Marked library to render the preview of the badge markdown. I could have done all of the UI stuff with Flask without any issues, but the fact that the entire thing now runs in the browser saves bandwidth, computing resources, and time.

You can see the transformation for yourself in the ezBadge GitHub repo. In the next iteration of ezBadge I plan on adding more choices for the types of badges that you can make. If you have any suggestions please feel free to leave a comment here or open up a github issue.

 

 

Introducing ezBadge

A few months ago I wrote about my struggles with Markdown Image Links. The entire reason why I was working on that before was to put cute little badges in my Github repos.

Today I took this a whole step forward and wrote a small web application that just “does the needful” for you.

ezBadge makes it easy to transform a regular Github Repo URL into a beautiful badge by writing the markdown for you and allowing you to just copy and paste it into your README.md file or anywhere else where Markdown is supported. You just feed it a valid Github repo URL and it spits out the Markdown along with a preview of what you will see if you put that markdown somewhere.

So far, the only type of Badge that it makes is a CircleCI badge but I plan on adding more in the near future and if there is a badge that you would like to see, please open up an issue for this project.