<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to send email to multiple recipients using map command with Python3? in Reporting</title>
    <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/464583#M7478</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;I am using splunk 8.0.1 on windows OS with Python3. &lt;BR /&gt;With help of &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt; answer from &lt;A href="https://answers.splunk.com/answers/489475/how-configure-an-alert-to-send-an-email-based-on-f.html" target="_blank"&gt;https://answers.splunk.com/answers/489475/how-configure-an-alert-to-send-an-email-based-on-f.html&lt;/A&gt;&lt;BR /&gt;I was trying below search-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; Your Base Search Here
 | outputlookup MyTempLookup.csv
 | stats count by EmailContact
 | map maxsearches=9999 search="|inputlookup MyTempLookup.csv
                                | search EmailContact=$EmailContact$
                                | sendemail to=\"$EmailContact$\" format=raw subject=myresults sendresults=true"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the search is returning results but it is not sending any mail. and when I checked internal logs below error I observed-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ERROR   sendemail:1428 - [HTTP 403] Client is not authorized to perform requested action;
Traceback (most recent call last):
  File "D:\Program Files\Splunk\etc\apps\search\bin\sendemail.py", line 1421, in &amp;lt;module&amp;gt;
    results = sendEmail(results, settings, keywords, argvals)
  File "D:\Program Files\Splunk\etc\apps\search\bin\sendemail.py", line 400, in sendEmail
    jobResponseHeaders, jobResponseBody = simpleRequest(uriToJob, method='GET', getargs={'output_mode':'json'}, sessionKey=sessionKey)
  File "D:\Program Files\Splunk\Python-3.7\lib\site-packages\splunk\rest\__init__.py", line 559, in simpleRequest
    raise splunk.AuthorizationFailed(extendedMessages=uri)
splunk.AuthorizationFailed: [HTTP 403] Client is not authorized to perform requested action
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note- If I try using only sendemail command then it is working and I am able to receive email.&lt;BR /&gt;Is there anything needs to be modified in sendemail.py command for python3.&lt;/P&gt;
&lt;P&gt;Below sample query I tried but it is not sending any email-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; index=_internal|stats count by sourcetype|eval EmailContact=if(sourcetype="splunkd","email@id.com","email2@id.com")
  | outputlookup MyTempLookup.csv| stats values(EmailContact) AS emailToHeader| mvexpand emailToHeader| map search="|inputlookup MyTempLookup.csv | where EmailContact=\"$emailToHeader$\"
     | fields - EmailContact
     | sendemail
        sendresults=true inline=true
               to=\"$emailToHeader$\"
        subject=\"Your Subject here: \"
        message=\"This report alert was generated by \$app\$ Splunk with this search string: \"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any idea what mistake I am doing in above query.&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Mon, 08 Jun 2020 20:28:19 GMT</pubDate>
    <dc:creator>ips_mandar</dc:creator>
    <dc:date>2020-06-08T20:28:19Z</dc:date>
    <item>
      <title>How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/464583#M7478</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I am using splunk 8.0.1 on windows OS with Python3. &lt;BR /&gt;With help of &lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/1406"&gt;@woodcock&lt;/a&gt; answer from &lt;A href="https://answers.splunk.com/answers/489475/how-configure-an-alert-to-send-an-email-based-on-f.html" target="_blank"&gt;https://answers.splunk.com/answers/489475/how-configure-an-alert-to-send-an-email-based-on-f.html&lt;/A&gt;&lt;BR /&gt;I was trying below search-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; Your Base Search Here
 | outputlookup MyTempLookup.csv
 | stats count by EmailContact
 | map maxsearches=9999 search="|inputlookup MyTempLookup.csv
                                | search EmailContact=$EmailContact$
                                | sendemail to=\"$EmailContact$\" format=raw subject=myresults sendresults=true"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;But the search is returning results but it is not sending any mail. and when I checked internal logs below error I observed-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;ERROR   sendemail:1428 - [HTTP 403] Client is not authorized to perform requested action;
Traceback (most recent call last):
  File "D:\Program Files\Splunk\etc\apps\search\bin\sendemail.py", line 1421, in &amp;lt;module&amp;gt;
    results = sendEmail(results, settings, keywords, argvals)
  File "D:\Program Files\Splunk\etc\apps\search\bin\sendemail.py", line 400, in sendEmail
    jobResponseHeaders, jobResponseBody = simpleRequest(uriToJob, method='GET', getargs={'output_mode':'json'}, sessionKey=sessionKey)
  File "D:\Program Files\Splunk\Python-3.7\lib\site-packages\splunk\rest\__init__.py", line 559, in simpleRequest
    raise splunk.AuthorizationFailed(extendedMessages=uri)
splunk.AuthorizationFailed: [HTTP 403] Client is not authorized to perform requested action
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note- If I try using only sendemail command then it is working and I am able to receive email.&lt;BR /&gt;Is there anything needs to be modified in sendemail.py command for python3.&lt;/P&gt;
&lt;P&gt;Below sample query I tried but it is not sending any email-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt; index=_internal|stats count by sourcetype|eval EmailContact=if(sourcetype="splunkd","email@id.com","email2@id.com")
  | outputlookup MyTempLookup.csv| stats values(EmailContact) AS emailToHeader| mvexpand emailToHeader| map search="|inputlookup MyTempLookup.csv | where EmailContact=\"$emailToHeader$\"
     | fields - EmailContact
     | sendemail
        sendresults=true inline=true
               to=\"$emailToHeader$\"
        subject=\"Your Subject here: \"
        message=\"This report alert was generated by \$app\$ Splunk with this search string: \"
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Any idea what mistake I am doing in above query.&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Jun 2020 20:28:19 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/464583#M7478</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2020-06-08T20:28:19Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/464584#M7479</link>
      <description>&lt;P&gt;One thing I noticed that it's not related to python3 since it is also not working for python2.&lt;BR /&gt;
Is there any way by which I can send email to multiple recepients as per condition &lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2020 10:47:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/464584#M7479</guid>
      <dc:creator>ips_mandar</dc:creator>
      <dc:date>2020-05-25T10:47:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/544557#M8898</link>
      <description>&lt;P&gt;I'd assume you are using the MAP command to send email per each event from your base search, since I found that you can simply use the sendemail command in your main search without using MAP command.&lt;/P&gt;&lt;P&gt;I found the following SPL works when using MAP with sendemail inside.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;... your base search ...
| table emailaddress ...
| map search="|makeresults |sendemail to="$emailaddress$" from="me@sample.com" incline=true sendresults=true subject=mysubject message=mymessage"&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 19 Mar 2021 17:41:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/544557#M8898</guid>
      <dc:creator>splunkyfun12721</dc:creator>
      <dc:date>2021-03-19T17:41:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/549955#M9049</link>
      <description>&lt;P&gt;i am a admin user and follow the similar query, but I got "&lt;SPAN class="t"&gt;sendemail:1428&lt;/SPAN&gt; &lt;SPAN class="t"&gt;-&lt;/SPAN&gt;&lt;SPAN&gt; [&lt;/SPAN&gt;&lt;SPAN class="t"&gt;HTTP&lt;/SPAN&gt; &lt;SPAN class="t"&gt;403&lt;/SPAN&gt;&lt;SPAN&gt;] &lt;/SPAN&gt;&lt;SPAN class="t"&gt;Client&lt;/SPAN&gt; &lt;SPAN class="t"&gt;is&lt;/SPAN&gt; &lt;SPAN class="t"&gt;not&lt;/SPAN&gt; &lt;SPAN class="t"&gt;authorized&lt;/SPAN&gt; &lt;SPAN class="t"&gt;to&lt;/SPAN&gt; &lt;SPAN class="t"&gt;perform&lt;/SPAN&gt; &lt;SPAN class="t"&gt;requested&lt;/SPAN&gt; &lt;SPAN class="t"&gt;action" when run sentemail inside the map command, the email could be send if I run it seprartely. do you know how to avoid this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 30 Apr 2021 06:06:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/549955#M9049</guid>
      <dc:creator>wangjianiu</dc:creator>
      <dc:date>2021-04-30T06:06:36Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/550134#M9057</link>
      <description>&lt;P&gt;Would the sendresults app on SplunkBase work for this issue?&lt;/P&gt;</description>
      <pubDate>Sun, 02 May 2021 05:04:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/550134#M9057</guid>
      <dc:creator>gjanders</dc:creator>
      <dc:date>2021-05-02T05:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/550608#M9066</link>
      <description>&lt;P&gt;it could work sometimes, but it does not support CSV attachment, a larger table in an email is not good, better to find why we have the authentication issue and use the Splunk sendemail&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 06 May 2021 07:30:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/550608#M9066</guid>
      <dc:creator>wangjianiu</dc:creator>
      <dc:date>2021-05-06T07:30:06Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557759#M9260</link>
      <description>&lt;P&gt;It's pretty simple, don't even need to use map command. Just enable send email alert action and in to: field set $result.email$ (email - depend upon your field name in Splunk result) and select trigger "for each result". Email will be send to the respective email address for each line of result.&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_to_different_recipients_based_on_search_results" target="_blank"&gt;https://docs.splunk.com/Documentation/Splunk/6.3.3/Alert/Emailnotification#Send_email_to_different_recipients_based_on_search_results&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 07:36:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557759#M9260</guid>
      <dc:creator>sirajnp</dc:creator>
      <dc:date>2021-06-30T07:36:15Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557767#M9263</link>
      <description>&lt;P&gt;for each result would send many emails to one receiver, and we want send subset result to different user, so this may not help&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 07:53:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557767#M9263</guid>
      <dc:creator>wangjianiu</dc:creator>
      <dc:date>2021-06-30T07:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: How to send email to multiple recipients using map command with Python3?</title>
      <link>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557768#M9264</link>
      <description>&lt;P&gt;Just use a stats by email address at the end. Then will have only one email per recipient.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Jun 2021 07:56:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Reporting/How-to-send-email-to-multiple-recipients-using-map-command-with/m-p/557768#M9264</guid>
      <dc:creator>sirajnp</dc:creator>
      <dc:date>2021-06-30T07:56:48Z</dc:date>
    </item>
  </channel>
</rss>

