Database mail trying to send 2 times and then failing

Our database mail was running for 3 years without problems, but since one week, we are constantly getting this error:

The mail could not be sent to the recipients because of the mail server failure. (Sending Mail using Account 1 (2021-10-13T22:31:21). Exception Message: Cannot send mails to mail server. (Failure sending mail.). )

Unfortunately this message is not very helpful. Database mail is always trying to send the mail 2 times (with 1 minute interval), then it finally fails.

  • Is there a way to find out why exactly it is failing? ?
  • Is there a way to reconfigure database mail, so that it tries more often or sends in other ways?

Whenevent how to use Mod multiple times

I need to use Whenevent inside NDSolve. The event is formed by Mod[t,ST1] && !Mod[t, ST2]. I’ve already read the documentation and previous questions about how Whenevent manages the event trigger.
What I need is that the action happens when Mod[t, ST1] is True but not when Mod[t, ST2] is True. Here is a simple code to represent the issue:

eqTime = {time'[t] == 1, time[0] == 0}; update = WhenEvent[Mod[t, 0.1] && !Mod[t,0.2], { a[t] -> a[t] + 0.1, Sow@a[t]}]; (*Not Working*) ic = a[0] == 0; {sol, data} =    NDSolveValue[{eqTime, update, ic}, a[t], {t, 0, 1},      DiscreteVariables -> a[t]] // Reap;  Plot[sol, {t, t0, 1}] 

The output should be a step function that increases at {0.1, 0.3, 0.5, 0.7, 0.9} which should also be the list stored in data variable.

display an input string many times

I’d like to create a function that add 2 to an integer as much as we want. It would look like that:

>>> n = 3  >>> add_two(n) Would you like to add a two to n ? Yes The new n is 5 Would you like to add a two to n ? Yes the new n is 7 Would you like to add a two to n ? No 

Can anyone help me please ? I don’t how I can print the sentence without recalling the function.

PostgreSQL Function – Finding the difference between 2 times

I want to create a simple function in Postgres to find the difference between 2 TIME – not TIMESTAMP. As show below, it accepts 4 parameters: hour, minute, second and expire (hour). In this example I have commented out seconds, just working on minutes.

CREATE OR REPLACE FUNCTION time_diff(hr INT, min INT, sec INT, exp_hr INT) RETURNS INT LANGUAGE plpgsql AS $  $   DECLARE     cur_time    TIME;     expire_time TIME;      diff_interval INTERVAL;     diff INT = 0; BEGIN     cur_time    = CONCAT(hr,  ':',  min, ':', sec) AS TIME; -- cast hour, minutes and seconds to TIME     expire_time = CONCAT(exp_hr, ':00:00') AS TIME;         -- cast expire hour to TIME      -- MINUS operator for TIME returns interval 'HH:MI:SS;     diff_interval = expire_time - cur_time;      diff = DATE_PART('hour', diff_interval);      diff = diff * 60 + DATE_PART('minute', diff_interval);      --diff = diff * 60 + DATE_PART('second', diff_interval);      RETURN diff; END; $  $  ; 

Example: 01:15:00 – 02:00:00 should give me 45 minutes, so I do the following and I get the correct answer.

select * from time_diff(1, 15, 0, 2); 

However, if I do this: 23:15:00 – 01:00:00 – the should give me 105 minutes (60 + 45).

select * from time_diff(23, 15, 0, 1); 

But the result I am getting is -1335. I am trying to work out where I have gone wrong here.

Also I am invoking DATE_PART functions, this seems to be a quite an expensive process in terms of CPU usage. Is there a better way of optimising this function. With the first example I am getting results in 0.007s on 2018 i7 Mac mini. Although I do think this function is quick, but could it be better?


How many times do you roll damage for Chain Lighting?

Chain Lightning has the following description:

You create a bolt of lightning that arcs toward a target of your choice that you can see within range. Three bolts then leap from that target to as many as three other targets, each of which must be within 30 feet of the first target.

The rules for damage rolls state:

If a spell or other effect deals damage to more than one target at the same time, roll the damage once for all of them. For example, when a wizard casts fireball or a cleric casts flame strike, the spell’s damage is rolled once for all creatures caught in the blast.

Assuming four available targets which of the following is correct?

  • Roll once for damage for all of the targets
  • Roll twice for damage, once for the first target, and once for the three subsidiary targets.
  • Roll damage separately for each targets

What happens if I use the Coiling Grasp Tattoo on the same target multiple times?

One of the new items in Tasha’s Cauldron of Everything is the Coiling Grasp Tattoo, a rather interesting uncommon that lets you damage and grapple enemies at range if they fail a Strength saving throw. Fascinatingly, it has no limitations on its uses – it lasts until the target successfully escapes the grapple, you move too far away from it, or, importantly here,

or if you use this tattoo on a different creature.

However, let’s picture a situation where I have a creature grappled using this tattoo, and my best course of action is to use the tattoo on the same creature again, to try and deal damage to it if it fails the saving throw. This time, however, the creature passed its saving throw…

… but I did not use the tattoo on a different creature. Am I right to assume the target is still grappled, just doesn’t take further damage this turn?