使用awk命令以html表格式发送邮件 [英] Sending mail with html table format using awk command

查看:52
本文介绍了使用awk命令以html表格式发送邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正尝试使用awk命令以html表格式发送邮件,如下所示:

I am trying to send mail in html table format using awk command as below:

(

echo "From: "

echo "Subject: testing of html table using awk"

awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print  "</tr>"} END{print "</table>"}' file.tmp

) | sendmail xxx@yy.com

我的文件(file.tmp)包含以下内容:

And my file(file.tmp) contains as below:

AAA 1 1 1 1 0 0

SAP 1 1 1 1 0 0

RTTC 1 1 1 1 0 0

PGW 1 1 1 1 0 0

但是我收到的不是HTML表格格式的邮件,而是HTML代码本身.

But I am not getting the mail in html tabular format but instead with html code itself.

AWK命令正确吗?还是我错过了什么?

Is the AWK command correct? Or am I missing something ?

推荐答案

您需要添加Content-type标头:

(
    echo "From: "
    echo "Subject: testing of html table using awk"
    echo "Content-type: text/html"
    echo
    awk 'BEGIN{print "<table>"} {print "<tr>";for(i=1;i<=NF;i++)print "<td>" $i"</td>";print  "</tr>"} END{print "</table>"}' file.tmp
) | sendmail xxx@yy.com

这篇关于使用awk命令以html表格式发送邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆