예제 #1
0
    def _sendmail(self, to, subject=None, text: str = None, html=None, attachments=None, cc=None, bcc=None):
        smtp = Smtp(self._username, self._password, self._server, self._port)
        msg = smtp.message(self._username, to, self._replyto, cc, bcc, subject, text, html, attachments)
        smtp.smtp()
        senderr = smtp.sendmessage(msg)
        del smtp

        return senderr
예제 #2
0
attachments = ('/home/crown/t.txt', '/home/crown/d_nb_0001.jpg')
html = \
'''
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <title data-lang="title">email confirm</title>
  </head>
  <body>
    <h2 data-lang="title">email confirm</h2>
    <p data-lang="notify">
      你可通过复制下列网址到浏览器地栏或单击下列网址进行邮箱验证:
    </p>
    <p>
      <a href="h">h</a>
    </p>
  </body>
</html>
'''

smtp = Smtp(username, password, server, port)
smtp.smtp()
#msg = smtp.message(from_, to, reply_to, cc, subject = subject, attachments=attachments)
msg = smtp.message(from_, to, html_message=html)
#print(repr(msg.as_string()))
smtp.sendmessage(msg)

del smtp