Sponsored Content
Top Forums UNIX for Advanced & Expert Users How to send email as HTML format with attachment ? Post 302478916 by pludi on Thursday 9th of December 2010 07:20:32 AM
Old 12-09-2010
There's no easy way to fulfill your requirements from the command line. Sending HTML emails: easy. Sending HTML emails with images and an attached PDF: not so easy. The problem is that you'll either have to provide a full URL for the images, or attach them too.

Instead of sending from the command line, I'd suggest taking a look at MIME::Lite. It even includes an example of how to send an HTML mail with images.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send an attachment and html text both in the same mail

Hi all, I am working on UNIX (Solaris28). I would like to send an email in which the body will be in html format and, in the same mail, a xls file has to be attached. I have tried this: the file is correctly attached but the body comes as html source and not formatted. If I do not attach the... (4 Replies)
Discussion started by: stefan.yu
4 Replies

2. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

3. Shell Programming and Scripting

unable to send an email attachment

i know its pretty repeated query, but i need to post it in this new thread coz i need it urgently uuencode /var/tmp/chandra/emaillist.txt emaillist.txt | mail -s "message with encoded attachment" am unable to send the attachment emaillist.txt present in the path /var/tmp/chandra/ Is... (11 Replies)
Discussion started by: cmaroju
11 Replies

4. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

5. Shell Programming and Scripting

Unable to send mail with inline html along with attachment. Please help!

The below code is not working. I am able to send only inline html or only attachment. When trying to do both, only inline html is sent without attachment. Please help! #!/bin/ksh (echo "Subject: Test Mail - HTML Format" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

6. Shell Programming and Scripting

html format email with attachment in unix

Team, I have the below code, which is working fine and it sends the html report using sendmail command. I want to attach one more file ( which goes as attachment ) in that email. How to achieve it. i tried with uuencode. But no luck :mad: outputFile="/tmp/out.html" ( echo... (2 Replies)
Discussion started by: itkamaraj
2 Replies

7. UNIX for Dummies Questions & Answers

Sending html email with html attachment

Hello, I have a script which is sending an html file as an attachment. #!/usr/bin/ksh export MAILTO="user@company.com" export CONTENT="/usr/tmp/file.html" export SUBJECT="EmailSubject" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (0 Replies)
Discussion started by: sreenathkg
0 Replies

8. Shell Programming and Scripting

Not able to send attachment with the email

Hi All, The below code is working fine for me. mailx -s hello abc@xyz.com <<EOT Hello !!! How are you? Regards Rahul EOT But i am not able to send csv file with the mail .Getting just themail but not the attachment. uuencode /path/s1.csv | mailx -s hello abc@xyz.com <<EOT... (9 Replies)
Discussion started by: rafa_fed2
9 Replies

9. Shell Programming and Scripting

How to send email HTML + PDF attachment?

I am attempting to write a script where I can pass in parameters ( to , from, the location of a pdf attachment ) and send an email that has HTML for the body content and a PDF as an attachment. I have failed to achieve this with sendmail and mutt. I recently found this. If there are any... (2 Replies)
Discussion started by: jvsrvcs
2 Replies

10. HP-UX

Unable to send attachment with html tables in UNIX shell script

Heyy, any help would be grateful.... LOOKING FOR THE WAYS TO SEND AN EMAIL WITH ATTACHMENT & HTML TABLES IN BODY THROUGH SHELL SCRIPT (LINUX)..NOT SURE, IF WE HAVE ANY INBUILT HTML TAG OR UNIX COMMAND TO SEND THE ATTACHMENTS. KINDLY HELP below is small script posted for our understanding..... (2 Replies)
Discussion started by: Harsha Vardhan
2 Replies
HTTP::Lite(3pm) 					User Contributed Perl Documentation					   HTTP::Lite(3pm)

NAME
HTTP::Lite - Lightweight HTTP implementation SYNOPSIS
use HTTP::Lite; $http = HTTP::Lite->new; $req = $http->request("http://www.cpan.org/") or die "Unable to get document: $!"; print $http->body(); DESCRIPTION
HTTP::Lite is a stand-alone lightweight HTTP/1.1 implementation for perl. It is not intended as a replacement for the fully-features LWP module. Instead, it is intended for use in situations where it is desirable to install the minimal number of modules to achieve HTTP support, or where LWP is not a good candidate due to CPU overhead, such as slower processors. HTTP::Lite is also significantly faster than LWP. HTTP::Lite is ideal for CGI (or mod_perl) programs or for bundling for redistribution with larger packages where only HTTP GET and POST functionality are necessary. HTTP::Lite supports basic POST and GET operations only. As of 0.2.1, HTTP::Lite supports HTTP/1.1 and is compliant with the Host header, necessary for name based virtual hosting. Additionally, HTTP::Lite now supports Proxies. As of 2.0.0 HTTP::Lite now supports a callback to allow processing of request data as it arrives. This is useful for handling very large files without consuming memory. If you require more functionality, such as FTP or HTTPS, please see libwwwperl (LWP). LWP is a significantly better and more comprehensive package than HTTP::Lite, and should be used instead of HTTP::Lite whenever possible. CONSTRUCTOR
new This is the constructor for HTTP::Lite. It presently takes no arguments. A future version of HTTP::Lite might accept parameters. METHODS
request ( $url, $data_callback, $cbargs ) Initiates a request to the specified URL. Returns undef if an I/O error is encountered, otherwise the HTTP status code will be returned. 200 series status codes represent success, 300 represent temporary errors, 400 represent permanent errors, and 500 represent server errors. See http://www.w3.org/Protocols/HTTP/HTRESP.html for detailled information about HTTP status codes. The $data_callback parameter, if used, is a way to filter the data as it is received or to handle large transfers. It must be a function reference, and will be passed: a reference to the instance of the http request making the callback, a reference to the current block of data about to be added to the body, and the $cbargs parameter (which may be anything). It must return either a reference to the data to add to the body of the document, or undef. If set_callback is used, $data_callback and $cbargs are not used. $cbargs may be either a scalar or a reference. The data_callback is called as: &$data_callback( $self, $dataref, $cbargs ) An example use to save a document to file is: # Write the data to the filehandle $cbargs sub savetofile { my ($self,$phase,$dataref,$cbargs) = @_; print $cbargs $$dataref; return undef; } $url = "$testpath/bigbinary.dat"; open OUT, '>','bigbinary.dat'; $res = $http->request($url, &savetofile, OUT); close OUT; set_callback ( $functionref, $dataref ) At various stages of the request, callbacks may be used to modify the behaviour or to monitor the status of the request. These work like the $data_callback parameter to request(), but are more verstaile. Using set_callback disables $data_callback in request() The callbacks are called as: callback ( $self, $phase, $dataref, $cbargs ) The current phases are: connect - connection has been established and headers are being transmitted. content-length - return value is used as the content-length. If undef, and prepare_post() was used, the content length is calculated. done-headers - all headers have been sent content - return value is used as content and is sent to client. Return undef to use the internal content defined by prepare_post(). content-done - content has been successfuly transmitted. data - A block of data has been received. The data is referenced by $dataref. The return value is dereferenced and replaces the content passed in. Return undef to avoid using memory for large documents. done - Request is done. prepare_post ( $hashref ) Takes a reference to a hashed array of post form variables to upload. Create the HTTP body and sets the method to POST. http11_mode ( 0 | 1 ) Turns on or off HTTP/1.1 support. This is off by default due to broken HTTP/1.1 servers. Use 1 to enable HTTP/1.1 support. add_req_header ( $header, $value ) get_req_header ( $header ) delete_req_header ( $header ) Add, Delete, or a HTTP header(s) for the request. These functions allow you to override any header. Presently, Host, User-Agent, Content-Type, Accept, and Connection are pre-defined by the HTTP::Lite module. You may not override Host, Connection, or Accept. To provide (proxy) authentication or authorization, you would use: use HTTP::Lite; use MIME::Base64; $http = HTTP::Lite->new; $encoded = encode_base64('username:password'); $http->add_req_header("Authorization", $encoded); NOTE: The present implementation limits you to one instance of each header. body Returns the body of the document retured by the remote server. headers_array Returns an array of the HTTP headers returned by the remote server. headers_string Returns a string representation of the HTTP headers returned by the remote server. get_header ( $header ) Returns an array of values for the requested header. NOTE: HTTP requests are not limited to a single instance of each header. As a result, there may be more than one entry for every header. protocol Returns the HTTP protocol identifier, as reported by the remote server. This will generally be either HTTP/1.0 or HTTP/1.1. proxy ( $proxy_server ) The URL or hostname of the proxy to use for the next request. status Returns the HTTP status code returned by the server. This is also reported as the return value of request(). status_message Returns the textual description of the status code as returned by the server. The status string is not required to adhere to any particular format, although most HTTP servers use a standard set of descriptions. reset You must call this prior to re-using an HTTP::Lite handle, otherwise the results are undefined. local_addr ( $ip ) Explicity select the local IP address. 0.0.0.0 (default) lets the system choose. local_port ( $port ) Explicity select the local port. 0 (default and recommended) lets the system choose. method ( $method ) Explicity set the method. Using prepare_post or reset overrides this setting. Usual choices are GET, POST, PUT, HEAD EXAMPLES
# Get and print out the headers and body of the CPAN homepage use HTTP::Lite; $http = HTTP::Lite->new; $req = $http->request("http://www.cpan.org/") or die "Unable to get document: $!"; die "Request failed ($req): ".$http->status_message() if $req ne "200"; @headers = $http->headers_array(); $body = $http->body(); foreach $header (@headers) { print "$header$CRLF"; } print "$CRLF"; print "$body$CRLF"; # POST a query to the dejanews USENET search engine use HTTP::Lite; $http = HTTP::Lite->new; %vars = ( "QRY" => "perl", "ST" => "MS", "svcclass" => "dncurrent", "DBS" => "2" ); $http->prepare_post(\%vars); $req = $http->request("http://www.deja.com/dnquery.xp") or die "Unable to get document: $!"; print "req: $req "; print $http->body(); UNIMPLEMENTED
- FTP - HTTPS (SSL) - Authenitcation/Authorizaton/Proxy-Authorization are not directly supported, and require MIME::Base64. - Redirects (Location) are not automatically followed - multipart/form-data POSTs are not directly supported (necessary for File uploads). BUGS
Some broken HTTP/1.1 servers send incorrect chunk sizes when transferring files. HTTP/1.1 mode is now disabled by default. AUTHOR
Roy Hooper <rhooper@thetoybox.org> SEE ALSO
LWP RFC 2068 - HTTP/1.1 -http://www.w3.org/ COPYRIGHT
Copyright (c) 2000-2002 Roy Hooper. All rights reserved. Some parts copyright 2009 - 2010 Adam Kennedy. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.12.3 2010-12-14 HTTP::Lite(3pm)
All times are GMT -4. The time now is 06:02 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy