我正在尝试在创建发票但每次失败时向本地主机发送邮件
邮件是否已成功创建并记录在数据库中,并且每件事都很好,但为什么我无法在收件箱中收到邮件?
我可以在这里得到一些帮助吗?这是我的代码:
@api.model
@api.returns('self', lambda value: value.id)
def create(self, vals):
invoice = super(exppen_invoice, self).create(vals)
for res in invoice:
body = """
<html>
<head>
<title>Inform of Invoice Creation</title>
</head>
<body>
<h1>Invoice Has been created</h1>
<p><strong>Dears</strong>
<br/>
There is an invoice has been created in
""" + str(res.date_invoice)
body += """;& with code ;&""" + str(res.bodes)
body += """<br/>and you can find this invoice<a href="/web#id=""" + str(res.id)
body += """&view_type=form&model=account.invoice&action=278>;& Here ;&</a>
<br/>
<strong>Thanks</strong>
</body>
</html>"""
mail_msg_gets = {
"type": "notification",
'email_from': "LiveConnect System <apps@net2do.com>",
'reply_to': "LiveConnect <support@net2do.com>",
"author_id": 1,
'partner_ids': [(6, 0, [res.partner_id.id])],
'model': 'account.invoice',
'res_id': self.id,
'record_name': 'Created Invoices',
'body': body,
}
mail_message_id = self.env['mail.message'].create(mail_msg_gets)
mail_mail_gets = {
"mail_message_id": mail_message_id.id,
'subject': 'Created Invoices',
'notification': True,
'auto_delete': False,
'model': 'account.invoice',
'res_id': self.id,
"state": 'sent',
'email_to': res.partner_id.email,
'body_html': body,
}
print("mail_mail_vals : ",mail_mail_gets)
mail_mail_id = self.env['mail.mail'].create(mail_mail_gets)
self.env['mail.mail'].send([mail_mail_id])
return invoice