发送消息时出错

2024-05-17 03:44:50 发布

您现在位置:Python中文网/ 问答频道 /正文

我想发一封电子邮件

html = get_html_mail(self.request, order)

email = EmailMultiAlternatives('Subject',
                         html,
                         'no-reply@natarelochke.ru',
                         # to=[order.shop.email])
                         to=['......@gmail.com'])
email.attach_alternative(html, "text/html")
email.send()

但有一个错误,当我尝试发送电子邮件时:

AttributeError at /success/

'HttpResponse' object has no attribute 'splitlines'

我怎么能修好它?你知道吗

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>

这是我的信息的html。这是渲染和应发送邮件地址


Tags: nosendgetstyleemailrequesthtmlru
2条回答

只需一直将render设置为render_to_stringty

您正在splitlines上的某处使用HttpResponseHttpResponse没有方法splitlines。错误不是由添加到问题中的代码段产生的。你知道吗

Source of the django's HttpResponse object

找到您试图让HttpResponse使用splitlines方法的地方。从删除HttpResponse上不存在的splitlines开始。你知道吗

相关问题 更多 >