Send an email from a controller

Sprint exists to make other phone companies look good!

Unfortunately, since no errors appear to come back, the text/email just vanishes into the void, I’m not sure what else to try. It works fine, all else being the same, for AT&T and Verizon. I’m guessing Sprint support would be a frustrating maze, but don’t have any other ideas. Anyone else?

have you considered putting a GSM modem in rather than using an email-to-text service for SMS? this way you can send an SMS direct from the controller instead of relying on an email service. the organization i work at has 18 or so controllers and each controller has a GSM modem attached to a serial port and all SMS messages are sent from there. we even accept SMS messages as a high-level control feature to start our generators.
might be an option for your client if the current system is failing?

another real option is to use instant messaging. check out the post
works with gtalk and jabber clients and coupled with an instant messaging app on your smart phone (like IMO on iOS) its pretty instantaneous (as long as there is an internet connection)

Okay all you email fans, we had a customer who wanted to do “unauthenticated email” (like our old / mem map stuff used to do) and apparently the SendEmail command won’t let you do that.

Although, I’d love to hear what “unauthenticated” means to you, since I’ve found a variety of options. We DID add a few options to the SendEmail command(s) in PAC Control, including this one in 9.3e firmware (from the readme): Added the ability to send an email with no user account name from within the strategy.

But that wasn’t going to cut it for a favorite OptoFan who contacted me with another “unauthenticated email” request. However, he was kind enough to donate the code he came up with. It uses the old mem map stuff, but, since it’s part of a strategy, saves some time since all that’s need is self-contained in the strategy. No restart required. He also points out that: “this sends to two separate email addresses, more can be added.”

BTW, before you copy/paste this into your strategy, please make sure you change those “two separate email address” he used for an example, or our IT folks might get upset. :slight_smile:

Add in Powerup:

  Server_IP = IpAddressStringToInt32("");// First write the Server IP address
  ntMemMapData[0] = Server_IP;
  ntMemMapData[1] = bitnot Server_IP; // 1s Complement
  Scratch_Pad_Bit_Status = WriteNumTableToIoUnitMemMap(2,0,TestEmail, 0xFFFFF1300000, ntMemMapData );//Server IP
  Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF1300004, 25 ); //Port #
  Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF1200004, MakeInt64(0, 2));
  Scratch_Pad_Bit_Status = WriteNumToIoUnitMemMap(TestEmail, 0xFFFFF120001C, 1 );

The next snippet goes in its own chart as a single pass after a trigger somewhere else:

  Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF130003A, "" ); //Email From
  Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF1300008, "" ); //Email To
  WriteStrToIoUnitMemMap(TestEmail, 0xFFFF130006C, "Oh Happy Day" ); //Email Subject Line
  DelayMsec(1000 );
  SetIoUnitEventMsgText(TestEmail, 0, Test_Email );
  Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 2, 0 );
  DelayMsec(1000 );
  Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 0, 2 );
  DelayMsec(300 );
  Scratch_Pad_Bit_Status = WriteStrToIoUnitMemMap(TestEmail, 0xFFFF1300008, "" );
  DelayMsec(1000 );
  SetIoUnitEventMsgText(TestEmail, 0, "Hi Ben" );
  Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 2, 0 );
  DelayMsec(1000 );
  Scratch_Pad_Bit_Status = SetIoUnitScratchPadBitsFromMomo( TestEmail, 0, 2 );
  DelayMsec(1000 );

Thanks for sharing, OptoDan!


I am trying to get my PAC-R1 to send an email (eventually with attachments) using Mary’s example chart. When I run the chart I get nResult = 202. From the documentation it looks like it should not give me a positive number for nResult (it will equal 0 for success, and a negative integer if it failed). However, in the documentation under status code -43:

“Received NACK (Negative Acknowledgement). The mail server returned an error (other than a 200- or 300-series response).”

I think I am getting a 200-series response, and I’m not sure what that means. Also, depending on what Port# I use (I tried 25, 465, and 587), I get nResult = -43. So I think they are related. Does anyone know what would cause this error? Or if someone can point me to where I can find documentation on 200- and 300-series status codes that would be very helpful too.


Hello jm54321 aka Jordan,
Welcome to the OptoForums! I’m sorry you’re having trouble.
Looks like you might be running into [U][B]this issue (KB84549).[/B][/U] If a beta is available, would you be interested in trying the not-quite-fully QA’d firmware?
BTW, what email server are you using? There are a few little weird things w/gmail’s servers…

Hi Mary, thanks for the reply. I’ll have to pass on the non-QA’d firmware for my current application. However, you are correct that I am using a gmail server, and I have a feeling the issue is still on my end. I haven’t found much info on the settings to use for gmail, except this brief website:

Do you have any other tips/tricks/advice for connecting with gmail servers?


Hey Mary,

I was just digging through the forums here and wanted to ask if there was any elaboration on the “weird things with Gmail’s servers”. We’ve been using a business Gmail account to send alarm notifications to various customers for quite some time now. For the most part, everything goes off without a hitch. Recently, I had a controller start returning 202 and -2104 errors. I ran through with Opto22 Support for quite awhile and we never really got anywhere. We ended up replacing the S1 and everything started working again, but it was quite a hassle. It’s a large customer site with a lot of floating point data to save.

Today, I’ve run into another customer where it appears to be similar. They’d been receiving their email alerts fine for quite some time. I was receiving the 202 error, and then after a restart of the controller, it’s switched to -2104.

Any ideas?