Search code examples
htmlbashsendmailhtml-emailmailx

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.

Everything's fine till here, but let's suppose there is some more data that is in form of *.csv files. How do I create hyperlinks and link them to some fields (for eg. File1, File2) in output.html file ?

The *.csv files will go as attachments in the same mail which will have output.html as the body.

The mail will be send from a Solaris 10 / RHEL 6 machine and I'm coding using only bash.

Please let me know if some more information is required.


Solution

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

    <a href="www.yoursite.com/files/file1">File 1</a>