problem with sending mail from txt file having HTML code via sendmail -t


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting problem with sending mail from txt file having HTML code via sendmail -t
# 1  
Old 09-14-2012
problem with sending mail from txt file having HTML code via sendmail -t

Hi,

i have the following code in shell named as test3.sh..

Code:
#!/bin/sh
. /home/<user>/.profile
export dt=`date "+%d%b%y"`
export tim=`date "+%d%b%y %HM:%MM"`

cd
export WD=`pwd`
SID="<sid>"
export SID

export ORACLE_SID=$SID
export ORACLE_HOME=/oracle/$SID/102_64
export PATH=$ORACLE_HOME/bin:/oracle/$SID:/usr/sap/$SID/SYS/exe/run:$PATH
export SAPDATA_HOME=/oracle/$SID
MAILFILE=/tmp/Total_user.mailfile.12648584.txt
/bin/cat ${MAILFILE} | /usr/lib/sendmail -t


and my file 'Total_user.mailfile.12648584.txt' contains the following HTML text:

Code:
Mime-Version: 1.0
Content-type: text/html; charset="iso-8859-1"
From: user@company.com
To: user@company.com
Cc: user@company.com
Subject: subject

<html>
<head>
  <title>Total</title>
  <style type=text/css>
    body {
       margin:10px 10px 0px 10px;
       padding:0px;
       font-family: verdana, arial, helvetica, sans-serif;
       font-size: 10px;
    }
    table {
       border-collapse: collapse;
       background-color:#FFF;
       font-family: verdana, arial, helvetica, sans-serif;
    }
    td {
       font-size: 10px;
       font-family: verdana, arial, helvetica, sans-serif;
       border:1px solid #006;
    }
  </style>
</head>
<body>
<FONT size=2><b>Please Find The Below</b></font>
<br><br>
<FONT face="Arial Black" color="#f87217" size=6><b>P</b></font>
<br><br>
<table width=400>
  <tr>
    <td bgcolor="#99CCFF" width=250><b>NAME</b></td>
    <td bgcolor="#99CCFF" width=250><b>TOTAL</b></td>
    <td bgcolor="#99CCFF" width=250><b>LOGON</b></td>
  </tr>
  <tr>
    <td>T</td>
    <td>27</td>
    <td>1</td>
  </tr>
  <tr>
    <td>H</td>
    <td>8</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>U</td>
    <td>103</td>
    <td>35</td>
  </tr>
  <tr>
    <td>HU</td>
    <td>20</td>
    <td>7</td>
  </tr>
  <tr>
    <td>R</td>
    <td>57</td>
    <td>7</td>
  </tr>
  <tr>
    <td>S</td>
    <td>4</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>K</td>
    <td>5</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>F</td>
    <td>4</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>R</td>
    <td>13</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>FR</td>
    <td>2</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>FR1</td>
    <td><font color="#FF0000">0</font></td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>FR2</td>
    <td>14</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>R07</td>
    <td>226</td>
    <td>99</td>
  </tr>
  <tr>
    <td>R8</td>
    <td>1</td>
    <td><font color="#FF0000">0</font></td>
  </tr>
  <tr>
    <td>A2</td>
    <td>43</td>
    <td>12</td>
  </tr>
  <tr>
    <td>Sq</td>
    <td>318</td>
    <td>13</td>
  </tr>
  <tr>
    <td>Pw</td>
    <td>234</td>
    <td>2</td>
  </tr>
  <tr>
    <td bgcolor="#4AA02C"><b>TOTAL</b></td>
    <td bgcolor="#4AA02C"><b>1079</b></td>
    <td bgcolor="#4AA02C"><b>176</b></td>
  </tr>
</table>
<br><br>
<font size=1>
This is an automatically generated email. Please donot reply. For more info, please contact<br>
 at <a href="mailto: user@company.com">user@company.com</a>.
</font>
<br><br><br>
</body>
</html>

when i run through command as 'sh test3.sh' it executes perfectly and send me the mail..
But when i schedule it in crontab, in cron log it is showing successful but no mail has been sent to me. it send mail to unix id as 'You have mail in /usr/spool/mail/root'.

i schedule in cron as follows:
Code:
17 09 * * * /oracle/<sid>/scripts/test3.sh


Kindly let me know anything more required and why it not sending mail to user@company.com

its urgent..thank you in advance

Moderator's Comments:
Mod Comment edit by bakunin: Please view this code tag video for how to use code tags when posting code and data.

Furthermore, please avoid "it's urgent" or something such. Nobody coming here has problem not needing to be solved and if you need an answer in a given response time consider hiring an expert. We are a forum, not a help desk.

Last edited by bakunin; 09-14-2012 at 06:48 AM..
# 2  
Old 09-14-2012
Did you put it in the crontab of the same user as you run the script manually with?
# 3  
Old 09-14-2012
i am new to unix...can you please elaborate...
i schudule as root..
on command line i use ora<sid>
what to do for scheduling in same user as orasid???
# 4  
Old 09-14-2012
If you run the script with user 'ora', you should put the cron entry in the crontab file of that user, not root.

You probably used 'sudo crontab -e' to edit the crontab file. Instead run it without using sudo.
# 5  
Old 09-14-2012
it works....
thanks a lot....
i schedule it with ora<sid> and it worked...
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Need help in sending html mail with attachment

Hi Everyone, I am facing problems in sending html mail with attachemnt. I will able to send mail with attachment (plain text ) using mailx -s and uuencode command and also html mail without attachment using sendmail option. However I am not able to send html mail along with attachment.Either... (2 Replies)
Discussion started by: karthik adiga
2 Replies

2. UNIX for Dummies Questions & Answers

Sending mail in UNIX with body and attachment(.txt) using sendmail command

Hi All, In my .ksh script, I am sending an email with body and attachment (.txt) using sendmail command. I am able to receive the attachement along with the body of the mail. But I am getting special characters along with the content in the .txt. Also the alignment is incorrect. Can you please... (7 Replies)
Discussion started by: KRR
7 Replies

3. Shell Programming and Scripting

Problem in sending inline html with an attachment using sendmail

MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=border --border Content-Type: text/html Content-Disposition: inline <html><body><h2>This text should be displayed with html formatting</h2></body></html> --border Content-Type: text/plain Content-Disposition: attachment This text... (2 Replies)
Discussion started by: thulasidharan2k
2 Replies

4. Shell Programming and Scripting

How to embed a html file in a mail sending from Linux box with uuencode or mailx?

How to embed a html file as subject in a mail sending from Linux box with uuencode or mailx or any other way? we do not want the file as attachment, it should be embedded in the mail subject. (2 Replies)
Discussion started by: johnveslin
2 Replies

5. UNIX for Advanced & Expert Users

Sendmail problems -- with sending mail

Hello, I am C. and I would like to send mail with Sendmail to my hotmail-account. But this doesn't work, the mail always returns in the file: /var/spool/mail/root. Probably there is something wrong with my SmartHost. I configured it like: define ( 'SMART_HOST','smtp.direct-adsl.be') -->... (1 Reply)
Discussion started by: caroline
1 Replies

6. Shell Programming and Scripting

Sending HTML attachment through mail

Hi I am new to unix and scripting.I am trying to send a html file as an attachment. SUBJECT="Type of Exceptions in Application" TO=Sushovan.Samals@gmail.com SPOOLFILE=/data/reg/tlogs/Monitor.html #echo "Send the E-mail message..." uuencode $SPOOLFILE $SPOOLFILE | mailx -s "$SUBJECT" $TO... (2 Replies)
Discussion started by: sushovan
2 Replies

7. Shell Programming and Scripting

Need to attach a txt file while sending mail

Hi, I need to attach a txt file while sending mail thru Unix. Please help me out in this.. -Charan. (9 Replies)
Discussion started by: charan81
9 Replies

8. UNIX for Dummies Questions & Answers

sending mail with html content

hi, I am new to unix. I need send html content as a mail from my sun-solaris2.6 work station. When I tried that the recipient gets it as html code with all the tags. any solutions? thanx in advance (2 Replies)
Discussion started by: gmchoudary
2 Replies

9. Shell Programming and Scripting

Sending mail from Unix - For html output

I have automated some checks - and I want to send a email when there is an issue. This is fine and I can send the email. However - I want to generate the email in html format so I can highlight any issues to a reader.. ie. If there is a disk space issue - then the email will highlight the... (2 Replies)
Discussion started by: frustrated1
2 Replies
Login or Register to Ask a Question