Microsoft Office 365 email does not work with ERPNext

New user here. I cannot set up Microsoft Office 365 in the email setup of ERPNext.

These are the settings I am supposed to use as per the Microsoft documentation:
Server settings you'll need from your email provider - Microsoft Support.

Server Settings for Microsoft 365 for business

I know it does not work because I get an error when I try to send a password reset email or any test email for that matter. I even paid a guy on fiverr.com to try to figure it out and he couldn’t figure it out either…

Thanks,
Sean

Edit 1: The error message in the ERPNext Python Docker container when the email tried to send:

Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 415, in send_one
smtpserver.sess.sendmail(email.sender, recipient.recipient, message)
File “/opt/bitnami/python/lib/python3.7/smtplib.py”, line 867, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (530, b’5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [MWHPR22CA0004.namprd22.prod.outlook.com]', ‘Notifications erpnext@myijack.com’)

WARNING Property: Unknown Property name. [11:3: overflow-wrap]
Traceback (most recent call last):
File “/home/frappe/frappe-bench/apps/frappe/frappe/email/queue.py”, line 415, in send_one
smtpserver.sess.sendmail(email.sender, recipient.recipient, message)
File “/opt/bitnami/python/lib/python3.7/smtplib.py”, line 867, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (530, b’5.7.57 SMTP; Client was not authenticated to send anonymous mail during MAIL FROM [MWHPR10CA0052.namprd10.prod.outlook.com]', ‘Notifications erpnext@myijack.com’)

deleting…

Edit 2: a screenshot of the ERPNext email domain settings:

It may help if you could share the text of the error message that you see when you try to connect to the email service.

I’ve updated the question with the error message. Thanks.

Sean

Can you post a screenshot of the ERPNext Settings, Email domain page?

I’ve edited my question with a screenshot of the email domain settings page. Thanks! -Sean

Is the example email address an outlook email address that you have set up in Settings, Email Account?

Have you tried setting up a non outlook365 domain and email account?

@smino yes, it’s an Outlook email address that I have setup in Settings, Email Account.

Since then I’ve created both a new free outlook.com email address (same failure), and a new free gmail.com email address (same failure).

I feel like I must be missing something in the email setup, but then again, I paid an expert on Fivrr.com to try to figure it out, and he couldn’t either.

My assumption is that I must first create an email domain in settings, and then I must go into the “email account” in settings and select a default “notification” email address, and put in my login credentials for that email address. I’ve done all that a few times now, with a few different email addresses, and it’s still not working. Why is it so hard to setup email (separate question, I guess…)? Seems way too hard for a simple thing.

Thanks a lot,
Sean

May we know the version of ERPNext and the source of the image?

Also, check your ERPNext error log and try https://account.live.com/Activity to see if your attempts to connect are seen on the server.

@smino here is the Docker Compose file I used to create all the Docker containers and install everything automatically on our AWS EC2 Ubuntu server. It’s v12.10.1 for ERPNext and the official image is from Docker Hub.

# This is a combination of ./installation/docker-compose-common.yml and ./installation/docker-compose-erpnext.yml and ./installation/docker-compose-networks.yml

version: '3'

services:
  ###################################################################
  # The following is from ./installation/docker-compose-common.yml
  mariadb:
    image: mariadb:10.3
    restart: on-failure
    env_file: .env
    environment:
      - DB_ROOT_USER=${DB_ROOT_USER}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      # - MYSQL_DATABASE=${MYSQL_DATABASE}
      # - MYSQL_USER=${MYSQL_USER}
      # - MYSQL_PASSWORD=${MYSQL_PASSWORD}
    volumes:
      - ./installation/frappe-mariadb.cnf:/etc/mysql/conf.d/frappe.cnf
      - mariadb-vol:/var/lib/mysql
    networks:
      - myijack-network  

  adminer:
    image: adminer:latest
    restart: always
    env_file: .env
    # ports:
    #   - 0.0.0.0:3000:8080
    expose: 
      - 8080
    networks:
      - myijack-network  

  redis-cache:
    image: redis:latest
    restart: on-failure
    expose: 
      - 6379
    env_file: .env
    volumes:
      - redis-cache-vol:/data
    networks:
      - myijack-network
   redis-queue:
    image: redis:latest
    restart: on-failure
    expose: 
      - 6379
    env_file: .env
    volumes:
      - redis-queue-vol:/data
    networks:
      - myijack-network

 redis-socketio:
    image: redis:latest
    restart: on-failure
    expose: 
      - 6379
    env_file: .env
    volumes:
      - redis-socketio-vol:/data
    networks:
      - myijack-network

  ###################################################################
  # The following is from ./installation/docker-compose-erpnext.yml
  erpnext-nginx:
    # image: frappe/erpnext-nginx:${VERSION}
    image:  frappe/erpnext-nginx:v12.10.1
    restart: on-failure
    env_file: .env
    environment:
      - FRAPPE_PY=erpnext-python
      - FRAPPE_PY_PORT=8000
      - FRAPPE_SOCKETIO=frappe-socketio
      - SOCKETIO_PORT=9000
      - LETSENCRYPT_HOST=${SITES}
      - VIRTUAL_HOST=${SITES}
      - LETSENCRYPT_EMAIL=${LETSENCRYPT_EMAIL}
    # # If using this Nginx as the main reverse proxy for the server (e.g. in local development):
    # ports:
    #   - "0.0.0.0:80:80"
    #   - "0.0.0.0:443:443"
    depends_on:
      - erpnext-python
      - frappe-socketio
      - frappe-worker-default
      - frappe-worker-long
      - frappe-worker-short
    volumes:
      - sites-vol:/var/www/html/sites:rw
      - assets-vol:/assets:rw
    networks:
      - myijack-network

  erpnext-python:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: on-failure
    env_file: .env
    environment:
      - MARIADB_HOST=${MARIADB_HOST}
      - REDIS_CACHE=redis-cache:6379
      - REDIS_QUEUE=redis-queue:6379
      - REDIS_SOCKETIO=redis-socketio:6379
      - SOCKETIO_PORT=9000
      - AUTO_MIGRATE=1
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
      - assets-vol:/home/frappe/frappe-bench/sites/assets:rw
      # # AWS RDS special config file
      # - ./mariadb/common_site_config.json:/home/frappe/frappe-bench/sites/common_site_config.json:rw
    networks:
      - myijack-network

  frappe-socketio:
    # image: frappe/frappe-socketio:${VERSION}
    image: frappe/frappe-socketio:v12.8.4
    restart: on-failure
    depends_on:
      - redis-socketio
    env_file: .env
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

  frappe-worker-default:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: on-failure
    command: worker
    depends_on:
      - redis-queue
      - redis-cache
    env_file: .env
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

  frappe-worker-short:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: on-failure
    command: worker
    environment:
      - WORKER_TYPE=short
    depends_on:
      - redis-queue
      - redis-cache
    env_file: .env
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

  frappe-worker-long:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: on-failure
    command: worker
    environment:
      - WORKER_TYPE=long
    depends_on:
      - redis-queue
      - redis-cache
    env_file: .env
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

  frappe-schedule:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: on-failure
    command: schedule
    depends_on:
      - redis-queue
      - redis-cache
    env_file: .env
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

  site-creator:
    # image: frappe/erpnext-worker:${VERSION}
    image: frappe/erpnext-worker:v12.10.1
    restart: "no"
    depends_on:
      - erpnext-python
    env_file: .env
    environment:
      - SITE_NAME=${SITE_NAME}
      - DB_ROOT_USER=${DB_ROOT_USER} # root if using MariaDB in a Docker container as opposed to AWS RDS
      - MARIADB_HOST=${MARIADB_HOST}
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - ADMIN_PASSWORD=${ADMIN_PASSWORD}
      - INSTALL_APPS=${INSTALL_APPS}
      # # Force re-creation of site even if it already exists
      # # Otherwise it will say "Connections OK. Site erp.myijack.com already exists"
      # - FORCE=1 
    # # Using command: new will run "bash /docker-entrypoint.sh new" on container creation
    # command: new
    volumes:
      - sites-vol:/home/frappe/frappe-bench/sites:rw
    networks:
      - myijack-network

volumes:
  # Following is from ./installation/docker-compose-common.yml
  mariadb-vol:
  redis-cache-vol:
  redis-queue-vol:
  redis-socketio-vol:
  # Following is from ./installation/docker-compose-erpnext.yml
  assets-vol:
  sites-vol:

networks:
  myijack-network:
    external:
      name: myijack-network

@smino Here’s the activity on that new test email address I created. All the login attempts were from my own IP address, as opposed to my AWS EC2 server’s IP address, where the ERPNext is installed.

Check Error logs and Email digest for relevant messages

Try bench enable-scheduler

See what: netcat smtp.office365.com 587 returns in your container

@smino I remember reading that “bench” is not installed and is not needed with the Docker installation (although I can’t find where I read that, but I’m pretty sure @revant_one wrote it somewhere). When I enter the “erpnext-python” Docker container, “bench” is not installed (i.e. the “which bench” Linux command returns nothing)

I installed netcat and ran the netcat smtp.office365.com 587 command in the “erpnext-python” container (I assume that’s the right container), and here’s the result:

220 MW2PR16CA0065.outlook.office365.com Microsoft ESMTP MAIL Service ready at Tue, 11 Aug 2020 18:18:59 +0000

Is there a frappe-bench folder? You must enter that folder to execute bench commands , something like: cd ~/frappe-bench, then enter your bench commands

Not sure this has anything to do with network connection , rather a setup / authentication snafu. Has any email setup worked?

Here’s what it looks like in my terminal, when I enter the erpnext-python Docker container:
root@2c080a1955ec: /home/frappe/frappe-bench/sites#

No email setup has worked so far.

Try from /home/frappe/frappe-bench

Do your Error log list have entries that look like this for both Outlook and Gmail? I’v tried using Outlook and this is what I see:

A Google search of the terms suggests it may be something to do with MS profile updating or somesuch.

There is no bench in docker images for production setup.

Does this help?

Bench commands from frappe framework now work in docker. (currently develop branch)

2 Likes

I had the same issue, I had a tech at Microsoft who helped me set up, if you have your own domain at office365, you have to check in your office365 account what smtp server you need to enter, in my case it was ******-com.mail.protection.outlook.com ( representing my domain).

1 Like

Hi Chaim,

Can you please tell me what you used for IMAP server? I see you used the one you mentioned for SMTP but what about IMAP?

outlook.office365.com
Port 993