Author Topic: Multiple Email Recipients  (Read 6323 times)

wittmane

  • Newbie
  • Posts: 5
  • I'm a llama!
    • View Profile
Multiple Email Recipients
« on: July 18, 2014, 09:06:07 AM »
I have a Nano-10 and I want to send an email out to multiple people. Is there any way to send it to both simultaneously or CC someone. The only way I can think of is to send the same email multiple times, just with different recipients, which I would rather not do. Is there some more efficient way of doing this?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Multiple Email Recipients
« Reply #1 on: July 18, 2014, 10:04:31 AM »
The built-in <EMAIL> command can only specify one recipient at a time so you do need to execute the command one at a time. One easy way is to setup an email address at your company email server that will automatically forward to multiple recipients (most Cpanel based webserver has this capability) and the PLC only need to send to this one single address.

If you want the PLC to do the job directly, then you will need to handle the SMTP protocol directly as you can specify multiple lines of

RCPT To:<destination e-mail address>

An example program where you use the TBASIC to interact with SMTP server can be found at the following forum thread:

http://www.triplc.com/yabbse/index.php?board=2;action=display;threadid=1608

The purpose of the program was to handle authentication required by some SMTP server. You can modify the program to use it to manage multiple RCTP_TO: recipients.

For more information on how SMTP server wrok, check this:

http://technet.microsoft.com/en-us/library/aa995718%28v=exchg.65%29.aspx

where you can use telnet to directly interact with an SMTP server to send an email.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS

wittmane

  • Newbie
  • Posts: 5
  • I'm a llama!
    • View Profile
Re:Multiple Email Recipients
« Reply #2 on: July 18, 2014, 01:36:26 PM »
Here is what I have:
Code: [Select]
PRINT #4 "<EMAIL email1@example.com>"
PRINT #4 "SENDER: myemail@example.com"
PRINT #4 "SUBJECT: Email"
PRINT #4 "Body"
PRINT #4 "</>"

PRINT #4 "<EMAIL email2@example.com>"
PRINT #4 "SENDER: myemail@example.com"
PRINT #4 "SUBJECT: Email"
PRINT #4 "Body"
PRINT #4 "</>"
I would rather not do all of that twice, but if I have to, I can deal with it. The problem is that only email1 is receiving the email. I flipped their order, and the first email is the only one that goes through. What am I doing wrong?

support

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3171
    • View Profile
    • Internet Programmable PLCs
Re:Multiple Email Recipients
« Reply #3 on: July 18, 2014, 10:35:21 PM »
When you close an earlier connection try to provide a delay of 200ms or more to allow the previous connection to close properly so that a new connection can be made to send out the email. A more efficient method is to start a timer after sending the email to the first recipient and after the timer has timed out a custom function is called to send out subsequent emails.
Email: support@triplc.com
Tel: 1-877-TRI-PLCS