Tuesday, November 23, 2010

Send email through Gmail with GNU Emacs


Sending email from GNU Emacs through Gmail is pretty simple but it does take a bit of work to get everything configured.
The first step is to install starttls (direct link). This allows Emacs to communicate with Gmail via SSL. Place the resulting starttls.el file anywhere on your load-path.
Now you need to configure your ~/.emacs file. Here is a good starting point:
; Setup email sending
(require 'smtpmail)
(require 'starttls)
(setq send-mail-function 'smtpmail-send-it
      message-send-mail-function 'smtpmail-send-it
      smtpmail-starttls-credentials '(("smtp.gmail.com" 587 nil nil))
      smtpmail-auth-credentials (expand-file-name "~/.authinfo")
      smtpmail-default-smtp-server "smtp.gmail.com"
      smtpmail-smtp-server "smtp.gmail.com"
      smtpmail-smtp-service 587
      user-mail-address "john@gmail.com" ; make sure to change this
      smtpmail-debug-info t)
Your login credentials are stored in a file named ~/.authinfo. Here is the format:
machine smtp.gmail.com login john@gmail.com password password123
Make sure to replace “john@gmail.com” with your email address and “password123” with your actual password. Also make sure there is no newline after the password.
Then be sure to set restrictive permissions for it:
chmod a-rwx,u+rw ~/.authinfo
Now restart GNU Emacs. You could probably eval-buffer here, but restarting the whole program is what finally got it to work for me.
Now you’re ready to send your first email. Type C-x m to begin composing a new message. Once you’re ready to send it, type C-c C-c (to send and close the buffer) or C-c C-s (to send and keep the buffer).

you are done it will send a mail from your gmail.

Thanks to :
http://ejd.posterous.com/send-email-through-gmail-with-gnu-emacs

No comments:

Post a Comment