1

I'm trying to enable gnus to work with Outlook server (https://outlook.office.com/owa). At first I tried to re-use my old configuration for gmail (which worked fine for several years), but it didn't work in Outlook case.

Then I googled a lot, and it seems that the only way to make it work is to have davmail mail gateway on your workstation, and configure gnus to connect to davmail over IMAP.

Before I start digging in davmail more deeply, I'd like to clarify:

  1. Is davmail really necessary?
  2. I only need a single mail client to connect via DavMail to Outlook. Am I right that I only need workstation configuration?
  3. If it is only workstation configuration, does it mean DavMail will only run as a GUI application? Can I not run it via service as a background process?

Below is my gnus configuration from gmail account which I tried to adopt for Outlook:

;;
(setq user-full-name "My Name")
(setq user-mail-address "my.email@outlook")

(setq smtpmail-auth-credentials "~/.authinfo")

(setq gnus-select-method
      '(nnimap "my_mail"
          (nnimap-address "outlook.office365.com")
          (nnimap-server-port 993)
          (nnimap-stream ssl)
          (nnimap-search-engine imap)
          (nnimap-authinfo-file "~/.authinfo")))

(setq smtpmail-stream-type 'ssl
       smtpmail-smtp-server "smtp.office365.com"
       smtpmail-smtp-service 587)

My ~/.authinfo :

machine outlook.office365.com login my.email@outlook password my_password port 993

Now when I start gnus it prints this in minibuffer:

Opening connection to outlook.office365.com via tls...
nnimap (my_mail) open error: ‘NO LOGIN failed.’.  Continue? (y or n)
Mark
  • 165
  • 6
  • I access Outlook from gnus; maybe show us what you have tried? – éric Jul 18 '20 at 13:38
  • @éric, I updated my question. – Mark Jul 20 '20 at 13:58
  • 1
    Retrieving an old copy of my .gnus: I had outlook as one of my secondary select methods. The only difference other than that is that I did not specify the port. on either the emacs spec or in authinfo. For sending, I had tls, not ssl, and outlook.office365.com, not smtp...., but you're not that far yet. – éric Jul 21 '20 at 11:59
  • I also specified "(nnimap-inbox "INBOX")" for selecting email but I imagine this is irrelevant if you cannot log in. Have you verified that outlook allows IMAP access (under "sync email" in settings via OWA)? I know that we had to get this set for our institutional accounts hosted by outlook. – éric Jul 21 '20 at 12:07
  • @éric, thanks for comment. I was reading `gnus` manual, but could not comprehend the meaning and purpose of `gnus-secondary-select-methods`. Does it have higher priority over `gnus-select-method`? If you don't mind, could you post a snippet of your gnus configuration? – Mark Jul 21 '20 at 17:29
  • gnus will use the select method *and* the secondary methods so this will not be an issue. I really do think that the issue is with Outlook itself not allowing imap access for your account. Have you checked in the settings for Outlook as mentioned above? – éric Jul 22 '20 at 12:46
  • @éric, I could not find "sync email" setting. Did you mean this setting is available in OWA web access? So I logged in over web (I'm in Firefox), clicked "Settings" in top right corner, clicked "Mail", there was nothing about syncing emails. – Mark Jul 22 '20 at 13:08
  • With owa, I click on the gear symbol, then on "View all Outlook settings" (at the bottom) and then "Email" and I see one entry which says "sync email". It could be that this is only for office365 outlook? – éric Jul 22 '20 at 13:47

2 Answers2

1

I had exactly the same issue and I made it work using an app-password (see link below) instead of my office 365 password.

https://docs.microsoft.com/en-us/azure/active-directory/user-help/multi-factor-authentication-end-user-app-passwords

Therefore, in ~/.authinfo you may want to have something like that:

machine outlook.office365.com login <email_address> password <pasword> port imaps 
machine smtp.office365.com login <email_address> password <password> port 587 

As a side note, I use ~/.authinfo.gpg (instead of ~/.authinfo); besides the fact that it is more secure, it seems to significantly speed up authentication on MacOs (for reasons unknown to me).

jfwm
  • 21
  • 4
  • thanks for the link. So I need to create app password using the link provided, and this password has to go in ~/.authinfo? – Mark Dec 16 '20 at 19:45
  • Indeed, I added a sample ~/.authinfo extract in the answer – jfwm Dec 17 '20 at 20:58
0

Many organizations (schools, universities, companies ...) do not allow the creation of app passwords, forcing actual two-factor authentication on users. In this case davmail is a working option.

For davmail one should choose either the option O365Interactive or O365Manual. (O365Interactive will need the right OpenJDK with OpenJFX, but will switch over to O365Manual if OpenJFX is missing.) Other options can stay with their default.

In the emacs configuration the following works for me for imap:

(setq gnus-secondary-select-methods
  '(
    (nnimap "localhost"
    (nnimap-address "localhost")
    (nnimap-server-port 1143)
    (nnimap-stream network))))

For smtp I have:

(setq gnus-posting-styles
  '((".*" ; Matches all groups of messages
    (address "My Name <my email>")
    (From "My Name <my-email>")
    ("X-Message-SMTP-Method" "smtp localhost 1025 my-email"))))

In .authinfo I have:

machine localhost login my-email port 1143 password my-password
machine localhost login my-email port 1025 password my-password

While I could make work the smtp configuration just by executing the block, for the imap configuration I had to restart emacs. Not even leaving gnus and restarting it would work.

newtothis
  • 11
  • 1