Emacs newsgroup 3: send and receive Gmail

Source: Internet
Author: User
Tags imap smtp auth starttls

My work and life depend heavily on Gmail and Emacs, and their combination makes me very happy. After sending and receiving Gmail via Emacs gnus, I don't need to go over the wall Because IMAP is not HTTP and is not on the wall. I can send and receive emails and retrieve Gmail emails in Emacs.

For details about how to configure, refer to a very important article:

Http://www.mostlymaths.net/2010/12/emacs-30-day-challenge-using-gnus-to.html

Now let's take a look at my configuration file. gnus. El.

(Setq user-full-name "chenshu ") (setq user-mail-address "csfreebird@gmail.com ");;;;;;;;;;;;;;;;;;;;;; language environment settings; (set-language-Environment 'Chinese-GB) (setq gnus-default-charset 'Chinese-iso-8bit gnus-group-name-charset-group-alist '((". *". cn-gb-2312) gnus-Summary-show-article-charset-alist '(1. cn-gb-2312) (2. gb18030) (3. chinese-iso-8bit) (4. GBK) (5. big5) (6. UTF-8 )) gnus-newsgroup-ignored-charsets '(unknown-8bit X-unknown iso-8859-1 ));;;;;;;;;;;;;;;;;;;;;; auto-image-file-Mode) (setq mm-inline-large-images t) (add-to-list 'Mm-attachment-override-types "image /*");; various sending settings; (setq gnus-posting-styles '((". * "(name" sheismylife ") (address" csfreebird@gmail.com ") (Signature" http://blog.csdn.net/sheismylife%n ubuntu11.10, emacs + gnus \ n "))));; you need this to be able to list all labels in Gmail; (setq gnus-ignored-newsgroups "") (require 'nnir );; and this to configure Gmail IMAP (setq gnus-select-method '(nnimap "Gmail" (nnimap-address "imap.gmail.com") (nnimap-server-port 993) (nnimap-stream SSL) (nnir-search-engine IMAP) (setq gnus-secondary-select-methods '(NNTP "news.newsfan.net ")));; my version of gnus in my Mac does not handle HTML messages; correctly (the one in the netbook does, I guess it is a different; version ). the following will chose plaintext every time this is; possible. (setq mm-discouraged-Alternatives '("text/html" "text/richtext"); available SMTP accounts. the format is; type of connection-account in the from field-SMTP server-; port-login name-password. you can leave the password field ;; as nil and Emacs will ask every time (defvar SMTP-accounts '(SSL "csfreebird@gmail.com" "smtp.gmail.com" 587 "csfreebird@gmail.com" "mypassword"); now lets configure smtpmail. el with your name and functions to send; mail using your SMTP accounts by changing the from field (require 'smtpmail) (setq send-mail-function 'smtpmail-send-It message-send-mail-function' smtpmail-send-It mail-from-style nil user-full-name "Chen Shu "smtpmail-debug-Info t smtpmail-debug-verb T) (defun set-SMTP (mech server port user password) "set related SMTP variables for supplied parameters. "(setq smtpmail-SMTP-server smtpmail-SMTP-service portsmtpmail-auth-credentials (list server port user password) smtpmail-auth-supported (list mech) smtpmail-starttls-Credentials nil) (message "setting SMTP server to '% s: % s' for user' % s '. "server port user) (defun set-SMTP-SSL (server port user password & optional key CERT)" set related SMTP and SSL variables for supplied parameters. "(setq starttls-use-gnutls tstarttls-gnutls-program" gnutls-CLI "starttls-extra-arguments nil smtpmail-SMTP-server serversmtpmail-SMTP-service portsmtpmail-auth-credentials (list (list server port user password )) smtpmail-starttls-credentials (list server port key CERT) (message "setting SMTP server to '% s: % s' for user' % s '. (SSL Enabled .) "server port user) (defun change-SMTP ()" change the SMTP server according to the current from line. "(save-excursion (loop with from = (save-restriction (Message-narrow-to-headers) (Message-fetch-field" from ")) for (Auth-mech address. auth-spec) in SMTP-accounts when (string-match address from) Do (cond (memq Auth-mech '(cram-md5 plain login )) (Return (apply 'set-SMTP (cons Auth-mech auth-spec) (eql Auth-mech 'ssl) (Return (apply 'set-SMTP-SSL auth-spec) (T (error "Unrecognized smtp auth. mechanic: '% s '. "Auth-mech) Finally (error" cannot infer SMTP information. "); the previous function will complain if you fill the from field with; an account not present in SMTP-accounts. (defvar % smtpmail-via-SMTP (symbol-function 'smtpmail-via-SMTP) (defun smtpmail-via-SMTP (recipient smtpmail-text-buffer) (With-current-buffer smtpmail-text-buffer (Change-SMTP) (funcall (symbol-value' % smtpmail-via-SMTP) recipientsmtpmail-text-buffer ));; this wraps send mail via SMTP mail, to be able to send multiple; messages with smtpmail.

My. authinfo file:

Machine imap.gmail.com login csfreebird@gmail.com password mypassword port 993

Now we will introduce how to use it.

After gnus is started, Shift + 6 will see the Server Buffer, select the Gmail server, and then the folder in Gmail will be seen. Enter key to enter and view the email.

F key, which can be replied. C-c sends an email.

U-key subscription, which is the same as normal gnus operations. Note that it is best to subscribe to inbox and All mails. The former is to enable inbox subscription and you will find that the emails you have read are easy to recognize, it is easy to find unread emails.

The latter means that when the cursor stays on All mails, you can use g to implement query prompts in mini buffer, and then enter keywords to perform email search.

If you want to check whether there is any new email, move the cursor over inbox and press G.

Enter the Enter key to query and sometimes you will not see any emails you have read in the past. Therefore, you can use c-u space to view all emails.

Appendix:

If there is an attachment, the e-mail body will end with a connection, move the cursor to that line, and press enter to prompt the download. Sometimes the attachments are in Chinese and cannot be saved directly by pressing enter. You need to press o to save them.

If you want to add attachments when sending an email, press CTR-C and press enter and then f.

If the email content is HTML code, you can move the cursor to the email's summary and press k h. gnus will save the email as an HTML file, open an external browser to browse the local HTML file.

To send an email, simply press m.

Enjoy your life.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.