Using mutt from command line or script


 
Thread Tools Search this Thread
Operating Systems AIX Using mutt from command line or script
# 1  
Old 02-27-2012
Using mutt from command line or script

Hello,
I am attempting to send emails from AIX 5.2 using either the mailx command or mutt. When I use mutt:
Code:
  mutt -a jim.txt -s "Test Email" me@mydomain.com

It sends the attachment, but it forces me into the interactive menu.

When I use mailx:
Code:
 cat data.txt | uuencode data2.txt | mailx -s "Test" myemail@mydomain.com

It sends the attachment, but carriage returns for each line are striped and it comes as all one line.

I eventually want to do this with a script, but not sure how to get this working. I have done some searching, but can't seem to find anything helpful. Can you provide me with some links to scripts that I could look at? Thank you.
# 2  
Old 02-27-2012
Windows clients expect \r\n in text files, UNIX uses \n. Translate the text file before sending.

Code:
sed 's/$/\r/' unix.txt > win.txt

# 3  
Old 02-27-2012
Hi Corona688,
The file is being written out by a Cobol program that places a Carriage Return, Line Feed at the end of each line. The uuencode seems to be removing the carriage return. The mail client mutt leaves it intact. Do you know of a way to use mutt at the command line without it bringing up the interactive menu? Thank you.
# 4  
Old 02-27-2012
uuencode is for encoding binary files and really ought to encode what you have verbatim. If carriage returns are missing on the other end, I suspect they're missing on the input too, for whatever reason.

Have you tried adding carriage returns?
# 5  
Old 02-27-2012
Hi Corona688,
I did some more searching and found that if I code the line this way:
Code:
 mutt -a jim.txt -s "Test Email" me@mydomain.com < /dev/null

It sends the attachment with the carriage return/line feed. Now I have to figure out how to get the from address in there as it sends it with out one. Any Idea's? Thank you for your help.
# 6  
Old 02-27-2012
Try this (works using Korn shell on Solaris, your options my vary):
Code:
#!/bin/ksh

# Convert line feeds from the source and write to attach.out.
unix2dos -437 -ascii data.txt attach.out

# Now uuencode attach.out and call it data.txt for the attachment name.
(print "Please review the attached file";uuencode attach.out data.txt) | mailx -s "Test" myemail@mydomain.com

exit 0

Note that the "attach.out" filename can be omitted from the unix2dos command, where then the original file will be overwritten with the converted version. This example preserves the original data.txt file.
# 7  
Old 02-27-2012
Hi Gary_W,
Thank you for the script, but I don't have unix2dos.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Mutt command email body

Hi Team, While sending the email using the mutt command, mail body not appearing properly and attachment it is showing without line breaks and i used the CSS Style (nowrapper )it is working fine. in this case how to handle the email body, please help me. (1 Reply)
Discussion started by: bmk123
1 Replies

2. Shell Programming and Scripting

How to send the log as it is through mailx or mutt command?

Hi, I am able to send the mail with attachment through mailx/mutt command.But i am seeing the log file statements all together when i tried to open from my outlook. log file have the details like below aaa bbb ccc when i tried to open it from my outlook after receiving the mail attachment... (1 Reply)
Discussion started by: Samah
1 Replies

3. UNIX for Beginners Questions & Answers

Exec command with mutt - turn on & off?

Hi Folks - Quick question around the exec command again. At the end of my script, I check for specific error codes that are returned from a process I execute within the shell script. Based on the error code, I send an email. Do I need to turn off exec feature prior to send each email so... (5 Replies)
Discussion started by: SIMMS7400
5 Replies

4. Shell Programming and Scripting

Mutt command error

Hello there, I am using "mutt" command to send e-mails. mutt -s "Mail subject line" $( printf -- '-a attachment_name') < "mail body file" "e-mail id" I wish to change the name of the attachment by appending the date to it. Something like "attachment_name_$DATE.html" in the mutt... (5 Replies)
Discussion started by: H squared
5 Replies

5. UNIX for Dummies Questions & Answers

Mutt command - email body with out file name

Hello All, I know we can put body inside a mail using -i option for specifying the file which contains body message, is there an option for me to specify body content instead of a file specification only using mutt? Below is not working and i don't see any options in manual page! ... (4 Replies)
Discussion started by: Ariean
4 Replies

6. UNIX for Advanced & Expert Users

HTML and attachment using mutt command

Hi All, I want to attach the file as well send html content in the mail body using mutt command or any other command.(uuencode is not present). Please help me. Thanks in advance (1 Reply)
Discussion started by: arukuku
1 Replies

7. Shell Programming and Scripting

How to change the sender's name or E-mail address in mutt command

Can any one help me in this ??? How to change sender's name or email address in Mutt command??? (4 Replies)
Discussion started by: sarathi
4 Replies

8. Shell Programming and Scripting

How to split a csv file and zip it and attach using mutt command?

We need to redirect the output of a query to .csv file each containing a specified number of lines.Then we should zip these files and send as attachment using mutt command. We tried using split -l 500 query_output.txt outputfile Since we are not sure about the exact number of files... (0 Replies)
Discussion started by: Jassz
0 Replies

9. Shell Programming and Scripting

How to attach multiple .csv files using mutt command

I need to attach all files starting with 'BusinessReport' using mutt command. It could be any number of files in that directory, say BusinessReport_01, BusinessReport_03, BusinessReport_04 etc. Is there a way to attach all files where filename like BusinessReport_* and sent it using mutt... (2 Replies)
Discussion started by: Jassz
2 Replies

10. Shell Programming and Scripting

How does mutt command pick senders Details

Hi All, We use mutt in one of our scripts to send files as a part of a batch job . The command works nicely but i want to know from where does mutt pick the sender details. As the sender id is different if i use mutt and Mail utility. I can not change the command to mail as it is a part of the... (1 Reply)
Discussion started by: amit1_x
1 Replies
Login or Register to Ask a Question