Citizen Problem Reporter - email notifications

132
3
Jump to solution
10-08-2020 01:41 PM
Labels (1)
Highlighted
New Contributor II

Is it possible to send emails to multiple recipients?

https://solutions.arcgis.com/local-government/help/citizen-problem-reporter/get-started/email-notifi... 

I've used very similar email code in the past in my own environment and have been able to send multiples and it looks like the code is written to work with multiple recipients but it will only send to the first one in my list.

I've tried ; and , as delimiters and verified that both emails are valid

If anyone else can email to multiples 'out of the box' then I will search another avenue, maybe they are being blocked as spam....

Thanks

Reply
0 Kudos
1 Solution

Accepted Solutions
Highlighted
New Contributor II

the better solution is to not mess with the send_mail.py but instead reconfigure the build_email function in servicefunctions.py to build a proper list. I changed the variable from 'email' to 'recipients' but regardless, this builds a list when supplied ; separated addresses in config file.

this still allows to use both an manual address or one from attribute table.

recipients = []
rr = settings['recipient'].split(';')
for r in rr:
if r in row.fields:
recipients.append(row.attributes[r])
else:
recipients.append(r)

View solution in original post

Reply
0 Kudos
3 Replies
Highlighted
MVP Regular Contributor
Highlighted
New Contributor II

Thanks, I got it working by manipulating the 'recipients'. I couldn't get the right syntax to flow from the json config file to the python.

a few notes:

  • Putting a list in the config errors the script
  • Putting "name1@email.com;name2@email.com" translates to a list with only one object ["name1@email.com;name2@email.com"]
  • I added this to the Python send_mail to switch to a proper list: 
    • recipientsList = recipients[0].split(';')
    • creates: ["name1@email.com", "name2@email.com"]

The link above (Ricky's) shows these scripts nice and compact with no config file, the full solution (top link) has these files broken apart and maybe no-one tested multiple recipients set from inside the config file.

Reply
0 Kudos
Highlighted
New Contributor II

the better solution is to not mess with the send_mail.py but instead reconfigure the build_email function in servicefunctions.py to build a proper list. I changed the variable from 'email' to 'recipients' but regardless, this builds a list when supplied ; separated addresses in config file.

this still allows to use both an manual address or one from attribute table.

recipients = []
rr = settings['recipient'].split(';')
for r in rr:
if r in row.fields:
recipients.append(row.attributes[r])
else:
recipients.append(r)

View solution in original post

Reply
0 Kudos