Automatic emails using bash and sendgrid


You would like to be able to automatically send some emails (ie reports) from a linux server, using a bash script that runs in cronjob, without installing an email server on the linux server.


  • Create an account in Sendgrid and follow the directions for using WebAPI with curl
  • Set up your bash script to use the API key and have a script like the following. If you want to use big or multiple files you will need to use a temporary file for the base64 encoding, as in the example below, as there is a limit in curl.
  • Add your script to crontab
  • Use tee command to send output to a file and email


    You would like to send the error output from a command or a script to both an error file and an email.


    By using tee, you could do the following:

    Using Postfix to send out emails from development environment in Rails


    You want to be able to send emails from your development enironment using Postfix in your (K)Ubuntu pc.


    First you would need to install postfix:

    and then you would need to change an option in postfix to not use tls, so change /etc/postfix/

    and change the smtpd_use_tls from yes to no:

    restart your postfix server:

    and then setup your config/development.rb as follows:

    Command line mail message with postfix in (K)ubuntu


    You have installed postfix in your local development machine (sudo apt-get install postfix), and you want to test sending emails from the command line using mail



    You would first need to install the mailutils package:

    then you can send an email by:

    and you can send it by pressing Ctrl+D

    Dreamhost – SquirrelMail – old-messages folder

    You have left a message in a squirrel mail account in dreamhost for a long time and it gets archived by dreamhost. According to the dreamhost you should be able to get to your archived messages, by looking at the old-messages folder.
    The problem is that just by logging in to squirrel mail the folder doesn’t get displayed on the left hand side.

    Log on to squirrel mail and go to ‘Folders’ menu at the top.
    In the ‘Create Folder’ put ‘test’ or anything that you would like in the text box, and make sure that in the dropdown box you select ‘INBOX.old-messages’, so your newly created folder is a subfolder of the ‘inbox/old-messages’ folder.
    Create the subfolder, refresh the page, and in your left hand the old-messages folder should appear.