Error send message

I'm trying to send an email

html = get_html_mail(self.request, order)

email = EmailMultiAlternatives('Subject',
                         html,
                         '[email protected]',
                         # to=[order.shop.email])
                         to=['[email protected]'])
email.attach_alternative(html, "text/html")
email.send()

But have error, when i try send email:

AttributeError at /success/

'HttpResponse' object has no attribute 'splitlines'

How i can fix it?

def get_html_mail(req, order):
    request = req

    return render(request, 'send_mail/send_message.html', {'order': order})

HTML

<!DOCTYPE html>
<html lang="ru">
<head>
<title>Форма заказа</title>
<meta charset="utf-8">
                            </tr>
                    </table>
                </td>
            </tr>
        </table>
    </td>
    <td class="padd" style="width:15px;" ></td>
</tr>
<tr>
    <td class="padd" style="width:15px;" ></td>
    <td></td>
    <td class="padd" style="width:15px;" ></td>

That is html for my message. it is render and should send on mail address

Upvotes: 0

Views: 253

Answers (2)

just set render to render_to_string ty all for the time

Upvotes: 1

Nrzonline
Nrzonline

Reputation: 1618

You are using the splitlines somewhere on a HttpResponse. The HttpResponse has no method splitlines. The error is not produced by the code snippet you added to your question.

Source of the django's HttpResponse object

Find where you are attempting to let your HttpResponse use the splitlines method. Start with removing the not existing splitlines on your HttpResponse.

Upvotes: 1

Related Questions