<?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 Re: Failed to send email due to encoding error in All Apps and Add-ons</title>
    <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460592#M56663</link>
    <description>&lt;P&gt;Hello @tmontney,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;UnicodeEncodeError: 'ascii' codec can't encode character '\u2003'&lt;/CODE&gt;  indicates an unicode character cannot be ascii-encoded. The u2003 character is an 'EM SPACE' : &lt;A href="https://www.fileformat.info/info/unicode/char/2003/index.htm"&gt;https://www.fileformat.info/info/unicode/char/2003/index.htm&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try to find where/how it gets in there.&lt;/P&gt;</description>
    <pubDate>Wed, 20 May 2020 17:16:57 GMT</pubDate>
    <dc:creator>PavelP</dc:creator>
    <dc:date>2020-05-20T17:16:57Z</dc:date>
    <item>
      <title>Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460586#M56657</link>
      <description>&lt;P&gt;From the splunkd.log:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -  Traceback (most recent call last):
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -    File "C:\Program Files\Splunk\etc\apps\sendresults\bin\sendresults_alert.py", line 305, in &amp;lt;module&amp;gt;
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -      sendemail(recipient, bcc, recipient_list[recipient].get('email_subj') , outbound, argvals)
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -    File "C:\Program Files\Splunk\etc\apps\sendresults\bin\sendresults_alert.py", line 145, in sendemail
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -      smtp.sendmail(sender, all_recipients, message)
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -    File "C:\Program Files\Splunk\Python-3.7\lib\smtplib.py", line 855, in sendmail
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -      msg = _fix_eols(msg).encode('ascii')
05-19-2020 16:36:03.808 -0500 ERROR sendmodalert - action=sendresults_alert STDERR -  UnicodeEncodeError: 'ascii' codec can't encode character '\u2003' in position 2239: ordinal not in range(128)
05-19-2020 16:36:04.317 -0500 INFO  sendmodalert - action=sendresults_alert - Alert action script completed in duration=2559 ms with exit code=1
05-19-2020 16:36:04.317 -0500 WARN  sendmodalert - action=sendresults_alert - Alert action script returned error code=1
05-19-2020 16:36:04.317 -0500 ERROR sendmodalert - Error in 'sendalert' command: Alert script returned error code 1.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Position in question was &lt;CODE&gt;&amp;lt;/td&amp;gt;&lt;/CODE&gt;. It was in the middle of the file, many came before and many came after. File was saved as UTF-8. Tried re-adding the tag, no effect. Tried minimizing the file, no effect. Eventually, I saved the file as ANSI and that did the trick. I do notice that the failure is coming from a Python library.&lt;/P&gt;

&lt;P&gt;Sendresults is 5.0.0, on Splunk 8.0.2.1.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:26:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460586#M56657</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-05-20T15:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460587#M56658</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;Can you provide some more context on the issue? It looks like you modified the alert action script based on what I see in line 7 of the code snippet? Does this happen on every use of sendresults? &lt;/P&gt;

&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:46:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460587#M56658</guid>
      <dc:creator>mockd</dc:creator>
      <dc:date>2020-05-20T15:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460588#M56659</link>
      <description>&lt;P&gt;The only thing I've modified was as instructed here, by you: &lt;A href="https://answers.splunk.com/answers/821371/sendresults-not-working-after-upgrade.html"&gt;https://answers.splunk.com/answers/821371/sendresults-not-working-after-upgrade.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:55:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460588#M56659</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-05-20T15:55:10Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460589#M56660</link>
      <description>&lt;P&gt;Context is I'm testing a simple report with sendresults. Sender, subject, and message body filled out. Everything else empty or unchecked. My only other one is an alert and it's working. I used it as a template for this report.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 15:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460589#M56660</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-05-20T15:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460590#M56661</link>
      <description>&lt;P&gt;Ah, ok. From that snippet it looked like line 7 was "new" but that might be from the python libraries. When you said you saved the file as ANSI it worked? When I was troubleshooting the other issue I had tested on windows with no issues.&lt;/P&gt;

&lt;P&gt;Is there a chance there's some odd unicode character in the sender/subject/body fields of the alert action?&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 16:07:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460590#M56661</guid>
      <dc:creator>mockd</dc:creator>
      <dc:date>2020-05-20T16:07:27Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460591#M56662</link>
      <description>&lt;P&gt;As a matter of fact, there should've been: &lt;A href="https://www.compart.com/en/unicode/U+03A9"&gt;https://www.compart.com/en/unicode/U+03A9&lt;/A&gt; However, when it was indexed by Splunk, it was converted to a "?". (Not sure if that was Splunk's doing or the script that sent the data.) To troubleshoot, I removed the HTML and the email sent OK.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 16:38:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460591#M56662</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-05-20T16:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460592#M56663</link>
      <description>&lt;P&gt;Hello @tmontney,&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;UnicodeEncodeError: 'ascii' codec can't encode character '\u2003'&lt;/CODE&gt;  indicates an unicode character cannot be ascii-encoded. The u2003 character is an 'EM SPACE' : &lt;A href="https://www.fileformat.info/info/unicode/char/2003/index.htm"&gt;https://www.fileformat.info/info/unicode/char/2003/index.htm&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Try to find where/how it gets in there.&lt;/P&gt;</description>
      <pubDate>Wed, 20 May 2020 17:16:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/460592#M56663</guid>
      <dc:creator>PavelP</dc:creator>
      <dc:date>2020-05-20T17:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/566072#M75097</link>
      <description>&lt;P&gt;Try setting the system default encoding as utf-8 at the start of the script, so that all strings are encoded using that.&lt;/P&gt;&lt;P&gt;Example -&lt;/P&gt;&lt;P&gt;import sys&lt;BR /&gt;reload(sys)&lt;BR /&gt;sys.setdefaultencoding('utf-8')&lt;/P&gt;&lt;P&gt;The above should set the default encoding as utf-8 .&lt;/P&gt;&lt;P&gt;In most cases, the issue is that when you call str(), python uses the default character encoding to try and encode the bytes you gave it, which in your case are sometimes representations of unicode characters. To fix the problem, you have to tell &lt;A href="http://net-informations.com/python/iq/default.htm" target="_self"&gt;python&lt;/A&gt; how to deal with the string you give it by using .encode('whatever_unicode'). Most of the time, you should be fine using utf-8. So, stop using str() to convert from unicode to encoded text / bytes, properly use .encode() to encode the string:,&lt;/P&gt;&lt;P&gt;yourstring.encode('utf-8')&lt;/P&gt;&lt;P&gt;For python 3.x ,there is default encoding, hence there will be no issue of encoding.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Sep 2021 07:26:01 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/566072#M75097</guid>
      <dc:creator>nickbonz</dc:creator>
      <dc:date>2021-09-07T07:26:01Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/581146#M75894</link>
      <description>&lt;P class="lia-align-justify"&gt;I realize this is an old thread; but I just hit the same problem with sendresults, splunk 8.1.5, sendresults 5.0.3.&lt;/P&gt;&lt;P class="lia-align-justify"&gt;I was using a long comma separated list of email addresses in email_to.&lt;/P&gt;&lt;P class="lia-align-justify"&gt;Saw errors like:&lt;/P&gt;&lt;P class=""&gt;&lt;SPAN class=""&gt;" error="'ascii' codec can't encode character '\u202c' in position 29: ordinal not in range(128)"&lt;/SPAN&gt;&lt;/P&gt;&lt;P class=""&gt;The fix was to put a semicolon at the end of the email_to value.&lt;/P&gt;&lt;P class=""&gt;So&amp;nbsp;&lt;/P&gt;&lt;P class=""&gt;&lt;A href="mailto:foo@bar.com," target="_blank" rel="noopener"&gt;foo@bar.com,&lt;/A&gt;&lt;A href="mailto:joe@foo.com," target="_blank" rel="noopener"&gt;joe@foo.com,&lt;/A&gt;andy@whatever.org;&lt;/P&gt;&lt;P class="lia-align-justify"&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 17:55:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/581146#M75894</guid>
      <dc:creator>andygerberkp</dc:creator>
      <dc:date>2022-01-14T17:55:59Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/581165#M75895</link>
      <description>&lt;P&gt;You might have unknowingly "fixed" the issue not by adding the semicolon itself but by re-reading/resubmitting/whatever the setting.&lt;/P&gt;&lt;P&gt;Typically those "hidden" unicode errors appear when you're copy-pasting some text which looks ascii but isn't (typical problem for me was where I wrote a documentation for some project and MS Word kept "fixing" quotes in the code; same often happens with dashes or spaces). \u202c is a character using in isolating parts of a text in context of text direction &lt;A href="https://en.m.wikipedia.org/wiki/Bidirectional_text#Pops" target="_blank"&gt;https://en.m.wikipedia.org/wiki/Bidirectional_text#Pops&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jan 2022 22:03:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/581165#M75895</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2022-01-14T22:03:55Z</dc:date>
    </item>
    <item>
      <title>Re: Failed to send email due to encoding error</title>
      <link>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/582424#M75969</link>
      <description>&lt;P&gt;You were absolutely right; unprintable characters.&amp;nbsp; cat -v of the savedsearches.conf file revealed the problem, and a few tries in the GUI I was able to reset the search to remove the characters.&amp;nbsp; Thanks!&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jan 2022 17:53:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/All-Apps-and-Add-ons/Failed-to-send-email-due-to-encoding-error/m-p/582424#M75969</guid>
      <dc:creator>andygerberkp</dc:creator>
      <dc:date>2022-01-25T17:53:31Z</dc:date>
    </item>
  </channel>
</rss>

