ValueError at /success Неверный адрес в django EmailMultiAlternatives

Я хочу отправить сообщение на несколько email, но получаю следующее raise ValueError('Invalid address "%s"' % addr) ValueError: Invalid address "['ex1@gmail.com', 'ex2@gmail.com', 'ex404@gmail.com']"

        email_id = ["ex1@gmail.com","ex2@gmail.com","ex404@gmail.com"]
        username = name
        email = email_id
        ######################### mail system ####################################
        htmly = get_template('email/Email.html')
        d = { 
            's_id' : s_id,
            'username': username, 
            'tran_id' : tran_id,
            'amount'  : amount

            }
        subject, from_email, to = 'welcome', 'your_email@gmail.com', email
        html_content = htmly.render(d)
        msg = EmailMultiAlternatives(subject, html_content, from_email, [to])
        msg.attach_alternative(html_content, "text/html")
        msg.send()
msg = EmailMultiAlternatives("subject", html_content, "from@@gmail.com", ["to@@gmail.com", "to2@@gmail.com", "to3@@gmail.com"])  

Вы передали тип массива в другой массив, поэтому размерность массива была изменена. Пожалуйста, проверьте следующим образом.

        email_id = ["ex1@gmail.com","ex2@gmail.com","ex404@gmail.com"]
        username = name
        email = email_id
        ######################### mail system ####################################
        htmly = get_template('email/Email.html')
        d = { 
            's_id' : s_id,
            'username': username, 
            'tran_id' : tran_id,
            'amount'  : amount

            }
        subject, from_email, to = 'welcome', 'your_email@gmail.com', email
        html_content = htmly.render(d)
        msg = EmailMultiAlternatives(subject, html_content, from_email, to)
        msg.attach_alternative(html_content, "text/html")
        msg.send()
    
Вернуться на верх