AnvilWrappedError: Invalid Addresses

I get this error from anvil-app-server when requesting a user password reset email.

  2020-06-02 19:04:21,500 [ERROR anvil.app-server.run] Error report from client code:
  AnvilWrappedError: Invalid Addresses
  Traceback:
      <rpc>:0

  anvil-services/anvil/users.py:63

  anvil-services/anvil/users.py:469

  anvil-services/anvil/users.py:469

  app/CC_Test/Form1/__init__.py:15

I had a quick look at some of the source code and It looks to a novice that the smtp email “from address” might be hard coded to “accounts”.

This would make the “Invalid Addresses” error make sense as my email host will not allow a “from address” that is different to the “SMTP User”. However I could be reading the code completely wrong - never looked at clojure code before.

From core.clj Line 232:

(defn send-email! [to subject text]
  (if (get-in @util/*session-state* [:users :test-email-divert])
    (swap! util/*session-state* update-in [:users :test-email-divert] concat [{:to to, :subject subject, :text text}])
    (binding [email/*use-quota* false
              email/*require-service-config* false]
      (email/send! {:from_name    (if (app-data/abuse-caution? util/*session-state* util/*app-id*)
                                    "Accounts"
                                    (str (:name util/*app*) " Accounts"))
                    :from_address "accounts"
                    :to           to
                    :subject      subject
                    :text         text}))))

Can someone check if I am understanding the code correctly and if my conclusion is correct if there is a work around.

Sorry for the double post I did the noob thing and posted multiple questions in one topic.

A little more clarification on this:

The error I’m getting now I believe is due to the “from-address” not being the same as my smtp user.

My host does not allow a different “from-address” (or alias) to the smtp user.

I think there needs to be an option in config to set the “from-address”.

In my case “from-address” needs to be the same as the “smtp-user” (“myaccount@mydomain.co.uk”) but I suspect in other smtp hosts this may not be the case.

How about Install fake-smtp-server via npm and see if it works first?

I’d like someone from Anvil to check my theory before I put more time into this.

Not sure how quick they normally respond to forum posts.

Hi @apearce,

If you’d like to customise the Users Service (including password reset emails), you can use the Custom user authentication library.

If you’d like us to make the from_address in the password reset email customisable, please create a Feature Request on this Forum.

3 posts were split to a new topic: Add the ability to configure the Users Service E-mails from_address

Split topic to add to feature requests.