#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    64
    Rep Power
    10

    Sendmail with attachment command line ?


    hi..

    Could somebody guide me how to send mail with attachment using sendmail command in unix ?

    Thank you,
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Posts
    168
    Rep Power
    7
    Code:
    mailx -s 'mail with attachement' pd@pd.com <<EOF
    Find attached the hosts and group files
    
    Regards
    pd
    $(unix2dos /etc/group | uuencode group.txt)
    $(unix2dos /etc/hosts |uuencode hosts.txt)
    EOF
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2005
    Posts
    64
    Rep Power
    10
    Hi..

    Thank for your reply..

    Actually, i can sent the email right now with HTML formatted. But, i do not know how to sent the attachment file from my code. My code as below:-

    Code:
    To: "BAHARIN HASAN"<baharin.hasan@gmail.com>
    from: "DATAONE SDN BHD"<admin@dataone.asia>
    Subject: test
    Content-Type: text/html
    charset="us-ascii"
    
    <html>
    <head>
    <title>Your Page Title</title>
    </head>
    
    <body>
    <center>
    <table border=0>
      <tr>
        <th><img border=0 src=/images/pulpit.jpg alt=Pulpit rock width=67 height=92 /></th>
        <th><p>&nbsp;</p><h2>Bill Statement</h2></th>
      </tr>
    
      <tr>
      <td><h4>Dear <ASMAH_AHMAD>,</h4>
      <p>Thank you for your valued subscription to our<br/>
         services.Your TM bill statement is now attached as <br/>
         an Adobe PDF file in this email.</p>
      <p>Thank You</p></td>
      <td><p>Account No.</p><p><12345></p>Statement Date.<p><12/12/2010></p></td>
      </tr>
    </table>
    <center><img src=example.jpg alt=example/></center>
    </center>
    </body>
    </html>
    I am used "sendmail" command and sample command as below:
    Code:
    cat file.txt |sendmail -t
    Thank you,

IMN logo majestic logo threadwatch logo seochat tools logo