String index out of range while sending email
<p>I'm running into this error: <a href="http://pastebin.com/hH1ZbeWZ" rel="nofollow">link</a>, while trying to send mail with Django EmailMultiAlternatives. I tried searching for this error but no luck, also I tried removing or changing every variable for email, but with no luck.</p>

<p>This is the code:</p>

<pre><code>def spremembapodatkovproc(request):
    if request.method == 'POST':
        req_id = request.POST.get('req_num', 'Neznan ID zahtevka')
        old_email = request.user.email
        old_name = request.user.get_full_name
        new_email = request.POST.get('email_new', 'Nov e-mail ni znan')
        new_fname = request.POST.get('fname_new', 'Novo ime ni znano')
        dokument = request.FILES.get('doc_file')
        komentar = request.POST.get('comment', 'Ni komentarja')
        # try:
        plaintext = get_template('email/usr-data-change.txt')
        htmly = get_template('email/usr-data-change.html')

        d = Context(
            {
                'old_email': old_email,
                'old_fname': old_name,
                'new_email': new_email,
                'new_fname': new_fname,
                'req_id': req_id,
                'komentar': komentar,
                'user_ip': request.META.get('REMOTE_ADDR', 'IP Naslova ni mogoÄe pridobiti.')
            }
        )

        subject, from_email, to = 'eBlagajna Sprememba podatkov', 'eblagajna@ksoft.si', ["info@korenc.eu"]
        text_content = plaintext.render(d)
        html_content = htmly.render(d)
        print(text_content)
        msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
        msg.attach_alternative(html_content, "text/html")

        msg.mixed_subtype = 'related'

        for f in ["templates\\email\\img1.png"]:
            fp = open(os.path.join(BASE_DIR, f), 'rb')
            msg_img = MIMEImage(fp.read())
            fp.close()
            msg_img.add_header('Content-ID', '&lt;{}&gt;'.format(f))
            msg.attach(msg_img)
        msg.send()
</code></pre>

<p>Thank you for your help.</p>

<p>The problem was with redundant wrapping list of emails in another list.</p>

<p>So basically variable <code>to = ["info@korenc.eu"]</code>, then when line run</p>

<pre><code>msg = EmailMultiAlternatives(subject, text_content, from_email, [to])
</code></pre>

<p>it wrapped <code>to</code> one more time with <code>[ ]</code> brackets. and <code>[to] = [["info@korenc.eu"]]</code>, but it supposed to be simple list. So by changing the problem line to</p>

<pre><code>msg = EmailMultiAlternatives(subject, text_content, from_email, to)
</code></pre>

<p>everything worked.</p>

python django email