Sponsored Content
Top Forums Shell Programming and Scripting Sendmail - Attachments & Subjects Post 303025274 by dakelly on Tuesday 30th of October 2018 05:15:52 AM
Old 10-30-2018
Sendmail - Attachments & Subjects

Hi All,

Not been around in a while. However I have been all over tinternet (google) for days looking for a solution.

Where I work has decided to use Sendmail on our Linux and Unix estate for sending emails via scripts. So I am hoping to eventually get a working solution for Sendmail and not any other program like mailx or mut.

I have installed sharutils to get uuencode working.

Sends subject
Code:
echo "Subject: Test from HOST" | sendmail recipient@domain.com

Code:
( echo "Subject: Test from HOST" ) | sendmail recipient@domain.com

Sends Subject & Body
Code:
MSG=/tmp/temp.txt
echo "This is in the body of the email" >> $MSG
( echo "Subject: Test from HOST"; cat $MSG ) | sendmail recipient@domain.com

Sends Attachments only
Code:
uuencode test.txt test.txt | sendmail recipient@domain.com


However I cannot get Attachments & Subject - which to be honest, does make sense to have.

Both send with Subject only
Code:
uuencode test.txt test.txt | ( echo "Subject: Test from HOST" ) | sendmail recipient@domain.com

Code:
uuencode test.txt test.txt | echo "Subject: Test from HOST" | sendmail recipient@domain.com


I have also tried the following to get an attachment, Subject & Body, but again this does not work, it sends a .dat file which when opened is just the contents withing the code (below) and nothing else
Code:
( echo "to: recipient@domain.com" 
echo "Subject: Test from HOST"
echo "mime-version: 1.0"
echo "content-type: multiple/related; boundary=messageBoundary"
echo ""
echo "--messageBoundary"
echo "contrent-type: text/plain"
echo ""
echo "Please find the document atttached." 
echo ""
echo "--messageBoundary" 
echo "content-type: text; name=test.txt" 
echo "content-transfer-encoding: base64"
echo ""
openssl base64 < /tmp/test.txt ) | sendmail -t -i

Can anyone help in getting attachments & subjects working with Sendmail or even better, Subject, Body & Attachments
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using Sendmail (& attachment)

Hi, This is my first thread. Iam trying the following: OS: Sun Database: DB2, Informix, Oracle * Get the status of the database (using database command line options) * pipe to a text file * send mail of the text file to receiptents. TODO1: First step i tried to send a test message.... (3 Replies)
Discussion started by: kenkanya
3 Replies

2. UNIX for Dummies Questions & Answers

sendmail attachments

Dear all, I've been working with AIX for, um, 15 years now and I have read all I can about the above, but I am stuck. Everything seems to point to using sendmail on the command line to embed a uuencoded attatchment will not work. Using something like "(cat plain.txt;uuencode attach.file... (4 Replies)
Discussion started by: rbatte1
4 Replies

3. Shell Programming and Scripting

sendmail with attachments

Hi, I got the following script from Ygor on this site: #!/usr/bin/ksh export MAILTO="email_address" export CONTENT="/export/home/aisdba/email_body.html" export SUBJECT="subject of email" ( echo "Subject: $SUBJECT" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (9 Replies)
Discussion started by: suthera
9 Replies

4. UNIX for Advanced & Expert Users

Email with multiple attachments & HTML body

I have a html file: # cat sample.html <html> <body> Sample HTML file</p> </body> </html> And I have two excel sheets (sheet1.xls & sheet2.xls) I want to send an email by having the sample.html as the message body and two spreadsheets as the attachments. I tried using the below command:... (12 Replies)
Discussion started by: BHM
12 Replies

5. Shell Programming and Scripting

Sendmail Script: Gmail cannot find attachments

Hi. I am using a script on HP-UX to send emails that include a Pdf attachment to clients. The scipt makes use of sendmail. The scripts works for everything except gmail. When I go on gmail via my Web Browser, I can see the message with the attachment, but if I try to view or download the... (2 Replies)
Discussion started by: Wahooka
2 Replies

6. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

7. Shell Programming and Scripting

Sendmail Png Attachments

I use sendmail to send html emails, my script works perfect and sends email with plain text attachment. Now i need to attache png file to the email and this attachment part is not working. ( echo "From: $FROM" echo "To: $TO" echo "MIME-Version: 1.0" echo "Subject: $SUBJECT" echo... (4 Replies)
Discussion started by: posner
4 Replies

8. Shell Programming and Scripting

Sendmail gz Attachments

Hi All, I have a problem again with sendmail content type . I am trying to attach the gz file to the html email but couldnt figure out even after extensive google. Here is my code. ( echo "From: $FROM" echo "To: $MAILTO" echo... (3 Replies)
Discussion started by: posner
3 Replies

9. Red Hat

/etc/aliases & Sendmail

I've recently migrated a Solaris 10 server, to Redhat. I've migrated all my crons & scripts and now I'm attempting to set all the aliases, to send to the appropriate accounts. I have a particular user defined in /etc/aliases, however, when a particular script is ran in cron, I do not receive any... (2 Replies)
Discussion started by: Nvizn
2 Replies

10. Shell Programming and Scripting

Mailing multiple PNG attachments using sendmail

Need assistance in using the below script and having multiple png file attachments in the same script . Your inputs are appreciated. I dont have uuencode , I use either mailx, sendmail, mpack . ( echo "to: samplemail@somewhere.com" echo "from: samplemail@elsewhere.com" echo "subject:... (2 Replies)
Discussion started by: ajayram_arya
2 Replies
All times are GMT -4. The time now is 02:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy