Multiple email address in email widget

hello!

it is possible to add multiple recipients to email widget?
or i have to init multiple Blynk.email() commands with 20 seconds “delay” between them?

i have a flood sensor, and would like to send warning email to all family members in case of basement flooding…

thanks!

This was asked before I think… Yes, here is one solution:

And setting up multiple timeout timers for each separate email address would also work.

yup, i have read that topic. but my question was, if the email widget or Blynk.email() supports multiple recipients or not.

…but after some experimenting, this is apparently not supported. i think i will try the gmail auto forwarding option.

Think of it like Blynk.virtualWrite() commands… one action per command.

Or use the timers…

void emailSend()
{
  Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 1

  timer.setTimeout(16000L, []() {
    Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 2
  });

    timer.setTimeout(32000L, []() {
    Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 3
  });

    timer.setTimeout(46000L, []() {
    Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 4
  });
}
1 Like

now this seems an elegant solution…
i just tried the gmail forwarding, it is doable, but not very nice.

hmm, actually i do not really understand this syntax:

timer.setTimeout(10000L, [] () {});

in the official simple timer docs for timer.setTimeout it is only this:

int setTimeout(long d, timer_callback f)

Call function f once after d milliseconds. The callback function must be declared as void f(). After f has been called, the interval is deleted, therefore the value timerId is no longer valid.

void callMeLater() {
    // do something
}

timerId = timer.setTimeout(1000, callMeLater);

but not a single word about [] () {} instead of the callback function…
could you point me toward the proper docs or explain a bit how this works?

It’s the way I would do it. Why add extra code when Google has it covered for you.

when you try to set up something like that in google, you will see. it is quite inconvenient, to add an email address to the forwarding list, the person with the new address has to send back a confirmation password to you, than you have to set up new filter for forwarding, etc.

if you later want to add a new person, or remove someone, you have to again meddle with the settings.

for me it seems much cleaner to remove / add a person by simply removing / adding a line of code…

also, if in the future i have to implement something like that in one of my clients project, than i have no other solution just code, because most clients are not capable to set up souch forwarding in google or other mail.

We have this in our plans, as well as some rework of notification (notifs, mail, twitter) widgets, but I have no ideas of the time when it will be done.

1 Like

no stress :wink: i will test the solution provided by the big respected @Gunner, and if it works, i’m totally fine with that.

Review below post (good stuff from @Fettkeewl):

2 Likes

thanks for the link, i have read all that topic and also @Jamin’s topic about shorthands, but still nowhere explains this syntax meaning…

timer.setTimeout(10000L, [] () {});

I don’t fully understand it either, but it uses something called Lambda Expressions and is basically a shorthand way of doing this…

void emailSend()
{
  Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 1
  timer.setTimeout(16000L, emailTwo);
  timer.setTimeout(32000L, emailThree);
  timer.setTimeout(46000L, emailFour);
}

void emailTwo() {
Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 2
}

void emailThree() {
Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 3
}

void emailFour() {
Blynk.email("my_email@example.com", "Subject", "Your message goes here");  // Email 4
}
2 Likes

ok, right now i’m reading the msdn lambda article, it perfectly makes sense now! this was the explanation i was looking for!

now i remember that back in the old days i’ve used such lambda functions in python too. but that was a long time ago, and python syntax is quite different than c++

thanks!

2 Likes

Glad you understand it… I just keep a sample on hand and copy paste it where needed :stuck_out_tongue:

Thanks @Gunner. This is a quicker substitute for my old standby.

void doNothing () {

}

Reading @Fettkeewl’s comments in linked post it is probably more memory efficient too. And you say you don’t teach coding here. :wink:

Sometimes it just slips out of us :stuck_out_tongue_winking_eye: ;)!

1 Like

Actually, we are waiting for design from @Pavel for that task. It is very easy to impelement.

I would like to add a vote for the ability to send to multiple recipients.

Perhaps this will help @pavel

RFC 2822 section 3.4 in fact describes how multiples should be defined:

When it is desirable to treat several mailboxes as a single unit
(i.e., in a distribution list), the group construct can be used. The
group construct allows the sender to indicate a named group of
recipients. This is done by giving a display name for the group,
followed by a colon, followed by a comma separated list of any number
of mailboxes (including zero and one), and ending with a semicolon.
Because the list of mailboxes can be empty, using the group construct
is also a simple way to communicate to recipients that the message
was sent to one or more named sets of recipients, without actually
providing the individual mailbox address for each of those
recipients.

That would give us this sample syntax:

 Blynk.email("actionteam:email1@example.com,email2@example.com;","alert" ,"Come urgently");

If, in the back end you are throwing the email string at a fully compliant RFC2822 mail server I would expect it to ‘just work’ but a small test of this syntax did not produce the expected mails. :frowning:

2 posts were split to a new topic: Massive delay with blynk notify messages getting pushed through