# How should catch send mail?

**URL:** <https://discourse.nodered.org/t/how-should-catch-send-mail/35643>\
**Category:** General\
**Created:** [10 November 2020 02:16 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643 "2020-11-10T02:16:13Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [10 November 2020 02:16 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/1 "2020-11-10T02:16:14Z")

</div>

I use the `email` node to send mail, in case I have not entered information for this `mail` node, the sending mail will fail.

I wanted to handle this error so I used the `catch` node, I initialize the default **isSendMail** variable to **true** , if there is a send mail error that catch changes the value to **false**.

Since I have a lot of mails, I finished sending it before I output the final results.  
But do not understand why time catch the send mail error occurs after the end of the send mail loop?  
I think when there is an error that has not entered information for the mail node, the catch time must happen first, right?  
※I used the `delay` node before the `email` node but the result still hasn't changed

 ![mail-node](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/f/af965b0f25602fcf9ea0518eea8567d543c40cbc.png)

Anyone with experience in handling send mail please advise me how well in this case.  
Thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2020 09:06 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/2 "2020-11-10T09:06:59Z")

</div>

Why is the sending failing? If it is because, for example, the server is not accessible, it probably waits for 20 seconds before giving up and signalling the error.

By the way, rather than using a loop, split the array (if it is an array) into a sequence of messages and pass them on to the email node. You may be able to use a Split node to do that.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [10 November 2020 09:24 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/3 "2020-11-10T09:24:46Z")

</div>

> [@Colin](#):
>
> Why is the sending failing?

Suppose send mail error in case of not input email information and password of sender in `mail` node

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [10 November 2020 09:30 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/4 "2020-11-10T09:30:40Z")

</div>

> [@Colin](#):
>
> If it is because, for example, the server is not accessible, it probably waits for 20 seconds before giving up and signalling the error.

Can this be determined using the `status` node?  
Is it possible to use the `status` node to determine if an email was sent successfully or failed?  
Looking forward to instructions. Thanks!

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2020 09:39 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/5 "2020-11-10T09:39:29Z")

</div>

Can what be determined with a status node? The fact that it has failed cannot be known until it has failed, which takes time if there is a network problem.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [10 November 2020 09:53 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/6 "2020-11-10T09:53:23Z")

</div>

So in case of using the `mail` node, it is okay to only handle the error of not entering the user + pass information of the sender?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [10 November 2020 11:27 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/7 "2020-11-10T11:27:53Z")

</div>

Sorry, I don't understand the question.

---

<div class="post-metadata">

**Author:** ![minhhn0205](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/minhhn0205/32/29062_2.png) [@minhhn0205](https://discourse.nodered.org/u/minhhn0205)\
**Post date:** [11 November 2020 04:31 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/8 "2020-11-11T04:31:50Z")

</div>

Sorry!  
In case of using the mail node, only handle errors not input information such as the sender's user, password, right?

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [11 November 2020 07:13 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/9 "2020-11-11T07:13:24Z")

</div>

Sorry, I still don't understand the question.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [10 January 2021 07:13 UTC](https://discourse.nodered.org/t/how-should-catch-send-mail/35643/10 "2021-01-10T07:13:40Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
