Sending email from Emacs

Sending email from Emacs is remarkably easy for Linux users. The following works for >=Emacs 24; it assumes you have a Gmail account.

1) Open Emacs and hit C-x m to bring up the unsent mail buffer
2) Write a test email and hit C-c C-c to send
3) At the prompts, choose SMTP and then enter for server.
4) Enter username and password
5) Say yes to save password to ~/.authinfo authentication file.
6) And that's it.  It really is that easy.

If you follow the above process you will see that the following are added to your .emacs file

1: '(send-mail-function (quote smtpmail-send-it))
2: '(smtpmail-smtp-server "")
3: '(smtpmail-smtp-service 25))

If you’ve saved the password you’ll see that the following has been written to the ~/.authinfo file.

machine login username port 25 password mypassword

If you’re worried about having that information stored as plaintext, Emacs will read from a ~/.authoinfo.gpg file, if you have GPG installed.

Recently, Gmail has updated its security policies to only accept logins from secure apps. You may have to disable this setting in order to access the account. Given this, and also how much is attached to a Gmail account nowadays, you may want to set up a spare Gmail account just for the purposes of sending email.

Reading Gmail

Setting up Emacs to read Gmail via Gnus isn’t that much harder. However, given the multimedia nature of so many emails nowadays, I don’t find this feature very useful anymore.
What I do find useful is being able to send emails from Emacs. This means I can quickly fire off an email without leaving the editor and thus breaking my workflow.
You can find out more about sending and reading email at


  1. Gheatza says:

    I get very god information from your blog. I already bookmarked your website to read other important post. I have problem with gmail , i set the all sittings correctly but when i press “Test Account Setting ” button give me errors,
    I tried more than times and the same probleme>


    1. admin says:

      Check your settings for less secure apps
      Go to
      and choose enable. Make sure you read the warnings and that you’re happy with this!


  2. neymarsabin says:

    How do i send file or attachments by this method?


      1. neymarsabin says:

        Thank You, for the information.


  3. Dariush says:

    Hi Tony,
    when I try the above, it opens up my outlook client as soon as I press C c Cc


  4. vikash kumar says:

    Great post thank you


Leave a Comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s