Outgoing emails can't be sent by individual user's email id

Hi Guys,

I’m just stuck with this issue of having outgoing emails sent as coming from the logged-in user’s own email address. It doesn’t work.

I always get an error like this:
(501, '<User>: sender address must contain a domain', u'User &lt;user@mydomain.com&gt;')

From this thread, @rmehta mentioned that

All users in erpnext use the common gateway, the emails will be sent by the individual users, but all replies will come to one id and they will automatically be tagged to the right document.

Please correct me if I understood it wrong - I take it @rmehta means each logged in user should be able to send emails from the ERPNext with their own email address as the sender, although the message will just be sent via a common gateway (or a common smtp account which is the default outgoing account?).

So in my email settings, I tried unchecking the Always use Account's Email ID as Sender for my default sending email account.

This should allow what I want right? - which is to let each user send emails as if sending from their own email address.

However, if I leave that option unchecked, the emails don’t get sent and I get those errors I mentioned above. If I check the box, the emails get sent, but they are coming from my default sending email address.

I think I can just make a little change to the source code fix this problem. I just don’t know where exactly should I look into. Can anyone point me to the right direction pls?

@Nimrod I think your email ids are formatted badly. The feature usually works as advertised (we use it ourselves)

@Nimrod

All emails are sent by the outgoing email account (i.e default@yourmail.com), but when you reply to the email message, the email of the user who send it will show up. (i.e yourownname@yourmail.com), at least that’s what happens on my ERPNext site.

I also have the option Always use Account's Email ID as Sender unchecked

Thanks for the reply, @rmehta. But I’m pretty sure they’re properly formatted, I’ve checked like a dozen times already. That’s why I’m really suspecting there’s a bug somewhere.

From the error message, it seems the code is converting the < > signs to their HTML equivalents &lt; and &gt;. So when it gets passed to the function that actually sends the email, it has been turned into a badly-formed email address already. And then it complains that the email address should contain a domain, because the email id passed is now turned into

User &lt;user@mydomain.com&gt;

instead of User <user@mydomain.com> which it is supposed to be.

Sorry, but please, if you could indulge me, which source files should I check for this? Or where else should I look into if it’s really not the formatting of the email ids?

This is exactly the same thing that happens to my installation and no problem with that if that’s what we intend for the system to do.

But we want to check that option Always use Account's Email ID as Sender so that the messages coming out from the ERPNext will be sent to the recipients as if the individual user used his own email account to send them, and not the default outgoing email account.

@Nimrod this seems to be fixed. Are you running the latest version?

@rmehta, I’ve just updated to ERPNext v6.25.5 and Frappe Framework v6.26.4. I still encounter the same problem.

Okay, I’ve fixed this issue by updating the database also (not just the frappe files).

For those who may encounter the same problem, I just ran the following update in the command line:

bench update --patch

Seems like the problem was not with the python files, but in the DB.