Setup Sendmail MTA in Cygwin (and basic Mutt tutorial)

This is a very quick guide to setting up the Sendmail mail transport agent in Cygwin.

Run the Cygwin setup-x86_64.exe program and install both sendmail and mutt.

Your machine has to have a domain name assigned to it for Sendmail to run. Most people name their computers without assigning a domain name. To assign a domain name open a Cygwin console as administrator (we are going to need this for the next couple steps) and enter:

cmd /c sysdm.cpl

Click the Change button to open the computer name change dialog and then click the More button to add a primary DNS suffix if you haven’t already assigned one. Here you add just the domain suffix in the form of mydomain.com. This will require a reboot of the computer.

After rebooting open a Cygwin administrative console again and enter:

sendmail-config install

This will prompt for the name and password of a dedicated system account for the Sendmail daemon. The suggested account name is root but you may want to change it to sendmail or something similar. When it prompts for a password be sure to create a really complex one. You will never be prompted for this password again.

Now you can open services.msc and start CYGWIN sendmail from there and set it to start automatically. You can also start Sendmail in the adminstrative console with /etc/rc.d/init.d/sendmail start

I also recommend to install the mutt mail client in Cygwin which you can then use to send and view mail sent via Sendmail. Here is a basic .muttrc file that you put in your home folder:

——————————————————————–

# mutt will prompt to create this if it doesn't exist
set folder=~/mail

set spoolfile=/var/spool/mail/$USER

# this only makes sense if folder is set to something useful
set record=+sent

set sort=reverse-date

set arrow_cursor=no

#Don't automatically advance to next message when modifying message
set resolve=no

set move=no

set markers=no

set askbcc=yes

set menu_scroll=yes

# pager will not move to the next message when at end of a message and invoke next-page function is invoked
set pager_stop

# map delete-char to a sane value
bind editor delete-char

bind pager previous-line
bind pager next-line

—————————————————————-
The first time you run mutt from a console window it will prompt to create the ~/mail folder if it doesn’t already exist. You can press enter to affirm the creation.

Now you can send a test mail to yourself. Type m to compose a new mail, enter your user name for the To: For Subject: enter whatever you want. After entering the subject you are in the Vim editor. Type a message and then press Esc shift z z (or Esc : w q) to write the message. Mutt will then show you the message ready to send. Type y to send the message.

Now close mutt by typing q and then restart it. You should see the message you just sent to yourself in the mailbox. Use the arrow keys of the keyboard to select messages from the list and press Enter to open them. While in a message press q to exit or r to reply. When viewing the mailbox press $ to refresh the list and see any new messages that may have arrived.

If you want to start retreiving mail from an account like Gmail with Mutt then look at the getmail package available in Cygwin and be sure to read Cygwin-specific documentation at /usr/share/doc/Cygwin/getmail.README

Check out procmail which is used to filter incoming mail and also the spambayes or spamoracle packages which are able to filter spam and read their corresponding Cygwin-specific documentation in /usr/share/doc/Cygwin/

For sending mail via Gmail or other service look at the ssmtp package and its documentation under /usr/share/doc/ssmtp/