如何在电子邮件正文unis Mailx或mail命令中发送HTML文件 [英] How to send HTML File in a e-mail Body unis Mailx or mail command
问题描述
有没有一种方法可以在Linux中使用mail
或mailx
命令将html文件发送到邮件正文中.我到处搜索,尽管有很多线程,却找不到任何有效的工具.在该线程上,我看到了 Mailx发送html消息,但没有任何效果.
Is there a way to send html file into a mail body using mail
or mailx
command in Linux. I googled around and did not find anything that's working though there are many threads. on of the thread i see Mailx send html message but nothing works.
我使用的是以下命令,但未按预期工作.
What i used are below commands but not working as expected.
$ mail -s "$(echo -e "This is Subject\nContent-Type: text/html")" kulfi@tap.com < OneView_Sheet.html
$ mailx -s "$(echo -e "This is Subject\nContent-Type: text/html")" kulfi@tap.com < OneView_Sheet.html
上面的命令改为发送html源内容,如下所示...
The above command instead sending the html source content as follows ...
<table border="1" class="dataframe">
<thead>
<tr style="text-align: right;">
<th></th>
<th>OV_NAME</th>
<th>Composer_Firmware</th>
<th>SAS_20_Firmware_Version</th>
<th>SAS12_Firmware_Version</th>
<th>VC_Firmware_Version</th>
</tr>
</thead>
<tbody>
身体上所需的示例:
推荐答案
尝试使用虚拟HTML表对mutt
起作用.下面的命令可以帮助您对电子邮件通知进行排序.
Trying with your dummy HTML table did worked with mutt
. Below command can help you to get your email notifications sorted.
mutt -e "set content_type=text/html" -e "set from=sender@tap.com" -s "This is Subject" kulfi@tap.com < OneView_Sheet.html
在mail
& mailx
失败是sendmail -t
Another common mechanism which can be preferred in case of mail
& mailx
failures is sendmail -t
echo To: kulfi@tap.com >mailheader.txt
echo This is Subject >>mailheader.txt
echo Content-Type: text/html >>mailheader.txt
cat OneView_Sheet.html >> mailheader.txt
cat mailheader.txt| sendmail -t
由于大多数常用的标准样式都支持mutt
和sendmail
,因此您可能不需要添加任何其他库/工具.
Since both mutt
and sendmail
are supported most of the standard flavours which are in general use, you may not need to add any additional libraries / tools.
这篇关于如何在电子邮件正文unis Mailx或mail命令中发送HTML文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!