简体   繁体   English

使用html代码发送邮件并添加超链接

[英]send mail with html code and add hyperlink

I'm creating a script which generates reports by querying information from various servers. 我正在创建一个脚本,该脚本通过查询来自各种服务器的信息来生成报告。 Once the data is generated it does some calculations and creates a HTML output file (let's call it output.html), that I need to send via mailx/mail/sendmail. 生成数据后,它会进行一些计算并创建一个HTML输出文件(我们将其称为output.html),我需要通过mailx / mail / sendmail发送该文件。

Everything's fine till here, but let's suppose there is some more data that is in form of *.csv files. 到这里一切都很好,但让我们假设还有更多以* .csv文件形式存在的数据。 How do I create hyperlinks and link them to some fields (for eg. File1 , File2 ) in output.html file ? 如何创建超链接并将其链接到output.html文件中的某些字段(例如File1File2 )?

The *.csv files will go as attachments in the same mail which will have output.html as the body. * .csv文件将作为附件放在同一封邮件中,邮件的正文将具有output.html。

The mail will be send from a Solaris 10 / RHEL 6 machine and I'm coding using only bash. 邮件将从Solaris 10 / RHEL 6计算机发送,我仅使用bash进行编码。

Please let me know if some more information is required. 如果需要更多信息,请告诉我。

So you want a hyperlink to the attached files? 因此,您需要一个超链接到附件吗? I don't think you can do that. 我认为您无法做到。 You would typically either link to a hosted file OR attach it. 通常,您要么链接到托管文件,要么附加它。 Hyperlinks need a location to point to, and as an attachment, there isn't a set location to trigger the download/opening. 超链接需要一个指向的位置,作为附件,没有一个设置好的位置来触发下载/打开。

To link to a hosted file, just place it on your server and do a standard href hyperlink tag: 要链接到托管文件,只需将其放置在服务器上并执行标准的href超链接标记即可:

<a href="www.yoursite.com/files/file1">File 1</a>
<a href="mailto:vengets@gmail.com?Subject=Hello%20again" target="_top"> Contact ME </a>

You need a mail server for sending mail. 您需要一个邮件服务器来发送邮件。 Use some serverside scripting language like PHP .. for sending mail. 使用某些服务器端脚本语言(如PHP ..)发送邮件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM