如何在电子邮件正文或Mail命令中发送HTML文件

问题描述 投票:0回答:1

在Linux中,有没有一种方法可以使用mailmailx命令将html文件发送到邮件正文中。我到处搜索,尽管有很多线程,却找不到任何有效的工具。在线程上,我看到Mailx send html message,但没有任何效果。

我使用的是以下命令,但未按预期工作。

$ mail -s "$(echo -e "This is Subject\nContent-Type: text/html")"  [email protected] <  OneView_Sheet.html

$ mailx -s "$(echo -e "This is Subject\nContent-Type: text/html")"  [email protected] <  OneView_Sheet.html

上面的命令代替如下发送html源内容...

<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>

所需的身体示例:

enter image description here

linux email html-email mailx
1个回答
0
投票

尝试使用您的虚拟HTML表可以与mutt一起使用。下面的命令可以帮助您对电子邮件通知进行排序。

mutt -e "set content_type=text/html" -e "set [email protected]" -s "This is Subject" [email protected] < OneView_Sheet.html

mailmailx失败时可以首选的另一种常见机制是sendmail -t

echo To: [email protected] >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

由于muttsendmail都被大多数常用的标准样式所支持,因此您可能不需要添加任何其他库/工具。

© www.soinside.com 2019 - 2024. All rights reserved.