[Solved] Problem with mail commands & format


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Problem with mail commands & format
# 1  
Old 10-05-2011
Question [Solved] Problem with mail commands & format

1.
I generated a log for the script.
log:
Code:
abc
def
ghi
ijk

If I use general (plain text) format for mail sending, it was displaying correctly with new lines where I have.
Eg:
Code:
abc
def
ghi
ijk

But I tried with HTML format using the code:
Code:
outputFile="sample.log"  
(  
echo "From: abc@exapmle.com"  
echo "To: def@example.com"  
echo "MIME-Version: 1.0"  
echo "Subject: Test"   
echo "Content-Type: text/html"   
cat $outputFile  
) | sendmail -t

The mail was like a continous lines, but in HTML format. No breaks in lines.
Eg:
Code:
abc def ghi ijk

2.
Also whats wrong in :
Code:
mail -r abc@example.com -s "Test Subject" def@example.com  < $log

showing error:
mail: Options MUST PRECEDE persons
# 2  
Old 10-05-2011
1-)change to echoes like this in your html fmt
Code:
(  
echo "<br>From: abc@exapmle.com<br/>"  
echo "To: def@example.com"  
echo "MIME-Version: 1.0"  
echo "Subject: Test"   
echo "Content-Type: text/html"   
) | sendmail -t

2-)try like this
Code:
mail -s "Test Subject" def@example.com <$log -- -f 'abc@example.com'

regards
ygemici
# 3  
Old 10-05-2011
Quote:
Originally Posted by ygemici
1-)
2-)try like this
Code:
mail -s "Test Subject" def@example.com <$log -- -f 'abc@example.com'

regards
ygemici
Same error:
mail: Options MUST PRECEDE persons

I am using Sun OS
# 4  
Old 10-05-2011
Quote:
Originally Posted by karumudi7
Same error:
mail: Options MUST PRECEDE persons

I am using Sun OS
try change "mail" to "maix"
Code:
# mailx -s "Test Subject" def@example.com <$log -- -f 'abc@example.com'

# 5  
Old 10-05-2011
Quote:
Originally Posted by ygemici
try change "mail" to "maix"
Code:
# mailx -s "Test Subject" def@example.com <$log -- -f 'abc@example.com'


Even mailx was also showing the same error.

The following is accepting:
Code:
mail -s "Sample Test" abc@example.com <  $log

Smilie

http://www.stuffadda.com
# 6  
Old 10-06-2011
Use "pre" tag in html to show your content. It will process the line breaks. Otherwise, you need to convert the "\n" to "<br>".

The code will look like this:

Code:
outputFile="sample.log"  
(  
echo "From: abc@exapmle.com"  
echo "To: def@example.com"  
echo "MIME-Version: 1.0"  
echo "Subject: Test"   
echo "Content-Type: text/html"   
echo ""
echo "<html><body><pre>"
cat $outputFile  
echo "</pre></body></html>"
) | sendmail -t


Last edited by MacMonster; 10-06-2011 at 01:48 PM.. Reason: Fixed some typos.
This User Gave Thanks to MacMonster For This Post:
# 7  
Old 10-07-2011
MySQL

Quote:
Originally Posted by MacMonster
Use "pre" tag in html to show your content. It will process the line breaks. Otherwise, you need to convert the "\n" to "<br>".
Many thanks.... Its worked.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need Script to ZIP/SAVE & then DELETE Log file & send a mail conformation for any error

ENVIROMENT Linux: RHEL 6.4 Log Path: /usr/iplanet/servers/https-company/logs Log Format: user.log.03-15-2015 I have log4j log rotation enabled rotating files on a daily basis. The rotated logs are NOT compressed & are taking up too much space. I need a script that will run daily that... (1 Reply)
Discussion started by: admin_job_admin
1 Replies

2. Shell Programming and Scripting

Grep commands & format

I have these grep commands and need to put them next each other (in horizontal layout). cat /tmp/dsmc.out |grep Done cat /tmp/dsmc.out |grep "Elapsed processing time:" cat /tmp/dsmc.out |grep "Client date/time:" cat /tmp/dsmc.out |grep "Total number of bytes transferred:" so that it... (6 Replies)
Discussion started by: Daniel Gate
6 Replies

3. Shell Programming and Scripting

[Solved] BASH - chaining TEST and COMMAND with && and II

Can you explain what this line of script is doing. What I have understood is : -- variable C is the name of a software which is either not installed, so it must be installed or allready installed and then should be update if newer version found -- branch B="$B $C" is to install the software --... (4 Replies)
Discussion started by: jcdole
4 Replies

4. Shell Programming and Scripting

Linux mail format problem

I am trying to use Linux mail command on red hat linux. It is working fine except when there is hardcoded "\n" characters in the file content i want to send. It is literally taking "\n" as text and message is not getting formatted to give newliine effect. I am using the following command: cat... (3 Replies)
Discussion started by: fundoo.code
3 Replies

5. Shell Programming and Scripting

Sort a the file & refine data column & row format

cat file1.txt field1 "user1": field2:"data-cde" field3:"data-pqr" field4:"data-mno" field1 "user1": field2:"data-dcb" field3:"data-mxz" field4:"data-zul" field1 "user2": field2:"data-cqz" field3:"data-xoq" field4:"data-pos" Now i need to have the date like below. i have just... (7 Replies)
Discussion started by: ckaramsetty
7 Replies

6. HP-UX

[Solved] How do I configure Unix Mail Server to use another Mail Exchange Server

We have configured our mail unix server and can send out emails automatically from applications running on unix to different people in our company as well as outside our company. However there is an outside client who is not receiving these emails because the settings on their mail server cannot... (4 Replies)
Discussion started by: Tenyhwa
4 Replies

7. Shell Programming and Scripting

How to format a character to look like an amount -solved

Hi All, I want to format the retrieved varchar2 value in the database to $9,999,999,990.00 but remained as a character value. Is it possible? Example: 378273.23 to $378,273.23 below is the code i want to implement: sqlplus -s ${USERNAME}/${PASSWORD}@${ORACLE_SID} << END1 >> $LOGFILE... (0 Replies)
Discussion started by: ryukishin_17
0 Replies

8. Shell Programming and Scripting

mail format problem:

i need to send 2 diff mail in a single script:Below the script #!/bin/ksh echo "enter the number" read num if then mail -s "test" unix@yahoo.com mail -s "test" 9886767000@nma.vodafone.in,9916138003@nma.vodafone.in else echo "test again" fi... (5 Replies)
Discussion started by: ali560045
5 Replies

9. UNIX for Advanced & Expert Users

Remote commands problem using RSH & Rexec

I have enabled the RSH and Rexec command in my HP-UX server but when i try to send any command to the server it returns Execute Permission Denied except commands like ls-l C:\rsh xxx.xxx.xxx.xxx -l mpac mxpkill 12 the mxpkill command work when I log to the server using telnet with the same... (0 Replies)
Discussion started by: fhuwaidy
0 Replies

10. UNIX for Dummies Questions & Answers

Problem running plsql & unix commands in 1 script

Hi, I need help again. When I run this shell script, it only runs the unld_date.sql piece and exits. How can I structure this to run all the way to the end? When I don't have the unld_date.sql piece in here, everything runs fine from the date compare piece all the way to the end. Thanks in... (5 Replies)
Discussion started by: siog
5 Replies
Login or Register to Ask a Question