相关疑难解决方法(0)

Python 中的 HTML 电子邮件

我正在尝试使用 smtplib 发送 HTML 电子邮件。但我需要 HTML 内容有一个使用字典中的值填充的表。我确实查看了Python网站上的示例。但它没有解释如何在 HTML 中嵌入 Python 代码。有什么解决方案/建议吗?

我也看了这个问题。我可以这样格式化吗?

.format(字典名称)

python smtplib

1
推荐指数
1
解决办法
9871
查看次数

使用Unicode发送HTML邮件

我修改了python文档中的示例,以测试电子邮件模块中的unicode.

#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, unicode_literals, print_function

import smtplib

from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText

# me == my email address
# you == recipient's email address
me = "my@email.com"
you = "your@email.com"

umlauts='German Umlauts: üöä ÜÖÄ ß'

# Create message container - the correct MIME type is multipart/alternative.
msg = MIMEMultipart('alternative')
msg['Subject'] = umlauts
msg['From'] = me
msg['To'] = you

# Create the body of the message (a plain-text …
Run Code Online (Sandbox Code Playgroud)

python email unicode python-2.7

1
推荐指数
1
解决办法
5288
查看次数

在HTML电子邮件中使用变量?

我正在使用此帖子发送使用Python发送电子邮件的信息

到目前为止,说明是完美的.我还有两件事要做:

  1. 在体内调用变量
  2. 添加附件

变量将是今天的日期.就是这个:

today = datetime.datetime.today ()
tday = today.strftime ("%m-%d-%Y")
Run Code Online (Sandbox Code Playgroud)

我知道使用mailx,您可以使用-a选项附加.

python html-email

1
推荐指数
1
解决办法
6287
查看次数

在 Python 中发送带有颜色格式的电子邮件

我有下面的 Python 代码,用于从 file 的内容向我的 ID 发送电子邮件filename。我正在尝试发送带有文本颜色格式的电子邮件。

有什么想法请指教。

def ps_Mail():
    filename = "/tmp/ps_msg"
    f = file(filename)
    if os.path.exists(filename) and os.path.getsize(filename) > 0:
        mailp = Popen(["/usr/sbin/sendmail", "-t", "-oi"], stdin=PIPE)
        msg = MIMEMultipart('alternative')
        msg['To'] = "karn@abc.com"
        msg['Subject'] = "Uhh!! Unsafe rm process Seen"
        msg['From'] = "psCheck@abc.com"
        msg1 = MIMEText(f.read(),  'text')
        msg.attach(msg1)
        mailp.communicate(msg.as_string())
ps_Mail()
Run Code Online (Sandbox Code Playgroud)

html python mime

1
推荐指数
1
解决办法
1万
查看次数

标签 统计

python ×4

email ×1

html ×1

html-email ×1

mime ×1

python-2.7 ×1

smtplib ×1

unicode ×1