ERPNext able to receive email but not able to send email

Sorry for posting yet another email related topic here, I know that there are tons of topics opened for this kind of question but after read through many of those and days of Google I still can’t solve my issue. Thanks in advance for helping.

My problem is: after setting my email account, I am able to received email in ERPNext, but the email I sent from ERPNext is not received in my client side. Which mean I send a document from ERPNext, it shows “sent” in Email Queue, I also got the email in my outlook app said it was sent (maybe because the “Append Emails to Sent Folder” option), but the receiver is not receiving the email.

Version:
Ubuntu: Ubuntu 20.04.2 LTS
Bench: 5.4.0
ERPNext: v13.x.x-develop () (develop)
Frappe Framework: v13.x.x-develop () (develop)

I checked:

  1. when sending the email, there is no alert pop up for errors (from the frontend it looks like no error).
  2. checked the error logs, no errors showing
    (Updates)
    previously there was no errors but now it shows the following error
  3. checked the scheduler.log file: (based on this result I assume it is sent)
  4. checked the worker.log: (based on this result I assume it is sent)
  5. frappe.log and bench.log nothing changed
  6. I also tried to send the email using the outlook app, it is working so I assume not Microsoft side problem
  7. I checked the connection from my ERPNext server to the outlook email server following this link. Successful until the EHLO command step, but the MAIL FROM command step it return “STARTTLS is required to send mail” error, not sure is it the problem.

my configuration:

I also tried another configuration which create a Email Domain first, then assign this Email Domain to the Email Account, but it is not working as well.

(Note: I also assigned this email account to an active user account because I saw some post said it is required but still not working)

Sorry for the very long post, I just wanted to give as much information as I can. Really appreciate that anyone could help. Thanks.

(Updates)
I tried to use the frappe.sendmail function in console looks like there is no error as well:
image

Can you check your mail server logs?
(if you have access to it)

Make sure you have entered correct port number. Also try ticking Use SSL for Outgoing

Hello @jk1117 . Welcome to the ERPNext community.

I’ve spent the past 5 days getting my head around the various permutations regarding email. Not an easy task as the documentation is practically useless.

I’ve had a similar error and resolved it by deselecting TLS and selecting SSL. However, doing this means you also have to change the port, usually to 465, not the conventional 587. Check with your mailbox hosting service provider to confirm the port they use.

Hope it’ll assist you.

1 Like

Hi @rtdany10 @EugeneP ,
Thanks for the advices.

As I checked the outlook mail server does not provide a SSL SMTP options but I try to changes it anyway, it prompt “Invalid Outgoing mail Server or Port” error and the UI freeze.

then I thought maybe “STARTTLS” and “TLS” are different, so I tried to untick the “Use TLS” options, same error prompted. Then I changed the port to 25 which is non TLS version for SMTP, same error occurred.

I do not have access to the mail server because I am using Outlook services (or I misunderstood you, correct me if I am wrong)

Previously we have another project having the same issues unable to send email (not with ERPNext though) and turns out it is because Outlook quarantine all our outgoing mail. So we thought this might be the same issue, but after we checked, no quarantined mail on Outlook side.

Currently I am still checking Google see if is it cause by generic SMTP configuration issues (not cause by ERPNext). Do let me know if you have any other suggestions. Thanks.

Have you tried deselecting both TLS and SSL and then try either port 587 or 25 or 2525.

I also recall reading somewhere that selecting both TLS and SSL might work, but cannot remember the port, probably 465.

Also ensure that on the Email Account configuration the Disable SMTP server authentication is deselected (ie Authentication:yes)

I’m also not sure whether smtp-mail.outlook.com and smtp.office365.com point to the same server, ie IP. If not then they might have different configurations.

Tried both selecting and deselecting, no luck. The UI straight out freezing for few minutes and show this error:
image

Then I check the mariadb processList there is a weird process (id:434528) blocking

Perhaps I should try to changed it manually in DB (although it should not be the correct way), will see how’s it goes.

“Disable SMTP server authentication” is deselected.

tried both smtp-mail.outlook.com and smtp.office365.com

Tried different configuration for TSL, SSL and Port with both smtp server:

for smtp-mail.outlook.com:

TSL SSL Port Result
Off Off 25 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off Off 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off Off 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off Off 587 Error 2 Prompted
Off On 25 “Invalid Outgoing mail Server or Port” error prompted
Off On 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off On 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off On 587 “Invalid Outgoing mail Server or Port” error prompted
On Off 25 Email Queue shows ‘Sent’ status, but not receiving at receiver mail box
On Off 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On Off 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On Off 587 Email Queue shows ‘Sent’ status, but not receiving at receiver mail box
On On 25 “Invalid Outgoing mail Server or Port” error prompted
On On 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On On 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On On 587 “Invalid Outgoing mail Server or Port” error prompted

for smtp.office365.com:

TSL SSL Port Result
Off Off 25 “Invalid Outgoing mail Server or Port” error prompted
Off Off 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off Off 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off Off 587 “Invalid Outgoing mail Server or Port” error prompted
Off On 25 “Invalid Outgoing mail Server or Port” error prompted
Off On 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off On 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
Off On 587 “Invalid Outgoing mail Server or Port” error prompted
On Off 25 Email Queue shows ‘Sent’ status, but not receiving at receiver mail box
On Off 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On Off 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On Off 587 Email Queue shows ‘Sent’ status, but not receiving at receiver mail box
On On 25 “Invalid Outgoing mail Server or Port” error prompted
On On 2525 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On On 465 Email Queue Stuck at ‘Sending’ status, Error 1 shows
On On 587 “Invalid Outgoing mail Server or Port” error prompted

Error 1 in Error Logs:

Error 2:

(Updates)
I asked my admin to check the Email Server Log in the Microsoft admin exchange center, and discovered that all the mail that I sent from ERPNext are sent to the sender.

(ex. abc@gmail.com send email to efg@gmail.com, but at the Email Server Log, all email are sent from abc@gmail.com to abc@gmail.com and no single email are sent to efg@gmail.com)

and I did received email in the sender inbox every time I send email from the ERPNext, (I thought it was because of the “Append Emails to Sent Folder” options) but at the “To:” field of the email it is correctly written the receiver email. I tried different receiver emails, same issue occurs so it is not the receiver side problem.

So maybe is something in the ERPNext did not configure correctly?

I tried different SMTP service:

Sendgrid, it prompted "imaplib.IMAP4.error: b’LOGIN failed.’ error
Gmail, same as Error 2 produced above (I already make sure the “allow less secure apps” is on)

so is it possible that something went wrong during installation so that all outgoing email account not working?

Refer to the below post for a relevant bug

I manually define each Email Domain, even for GMail, Yahoo, etc, in addition to my own-domain email accounts, and do not rely on the predefined services in the drop-down selection box. I’m not too sure where the email configuration detail is stored, in a file or in the DB, but to confirm my configuration has taken affect, I download an import template to view the detail.

I know phpMyAdmin has a feature to constantly check which tables have changed.
DBeaver can do a search for a specific value across all tables

DBeaver > F5 > Search > DB Full-Text > TextToSearchFor > Search > …

allows you to find any data in the DB.

You can also monitor your file system to see changes to any file with

find ~/frappe-bench/ -type f -mtime -0.1 -ls
grep -ir “SearchFor” ~/frappe-bench/

Also use the browser’s DevTools > Network > Headers > Form Data to indicate which API methods are being called when the changes are made in the WUI.

Other than that, I’m fed up with the poor SMTP implementation. It’s not a new complaint and the forum is filled to the brim with people having had problems with it way back many years.

@EugeneP

Thanks for continuously helping, I tried to install a clean frappe without ERPNext again and tested it, it is able to send email successfully. So further prove that is something wrong with the configuration of the instance currently we are working on, we are currently try to debug that.

Thanks again for helping.