Loading ...
Sorry, an error occurred while loading the content.

Re: MUA/Smtp client/script to send mails via a Postfix relay server

Expand Messages
  • Jeroen Geilman
    ... Yes; it s called nail(1) or mailx(1). $ nail -a -s recipient ... No. Please read the documentation for any command you need to
    Message 1 of 9 , Nov 28, 2011
    • 0 Attachment
      On 2011-11-28 16:40, Roger Goh wrote:
      > Quite desperate& sorry if this is OT.
      >
      > I have a Linux RHES 4.5 box that's on the same subnet as my Postfix
      > box. For security reasons, I'm not allowed to ftp/scp/sftp files between
      > this box& the Postfix server.
      >
      > I have the following Perl script which I wanted to use to mail (& attach
      > files) out to the outside but alas the Perl script below gave an error
      > that "Mime-Lite module is not available" on this server when I use it:
      > http://www.logix.cz/michal/devel/smtp-cli/
      >
      > The tool above has a --host (or --server) option which would have enabled
      > me to point to the Postfix server to enable email to be sent out from this
      > RHES 4.5 box via the Postfix box.
      >
      > It will take weeks for Change Managemt to approve installing Mime-Lite
      > module, so I'll need help on the following :
      >
      > a) is there an MUA (mailx, mutt, sendmail) that would enable me to
      > perform this same function of pointing to the Postfix server& attach
      > a file to be mailed out?

      Yes; it's called nail(1) or mailx(1).

      $ nail -a <yourfile> -s <yoursubject> recipient

      > Kindly provide the full syntax/example.

      No. Please read the documentation for any command you need to use.

      --
      J.
    • Roger Goh
      Yes, understand the syntax/example mutt & nail that Jeroen & Noel provided but sendmail.cf will need to be configured. I got the following script which someone
      Message 2 of 9 , Nov 28, 2011
      • 0 Attachment
        Yes, understand the syntax/example mutt & nail that Jeroen &
        Noel provided but sendmail.cf will need to be configured.

        I got the following script which someone has tested working
        on his postfix but I have a problem with RCPT TO:
        (need someone to tell me how to obtain a valid address for RCPT TO)

        Script:
        =====

        {
           echo 'helo me'
           echo 'MAIL FROM:<you@...>'
           echo 'RCPT TO: <someone@...>'
           echo 'DATA'
           echo -e 'To:someone@...\nMIME-Version: 1.0
        (mime-construct 1.9)\nContent-Type:
        application/octet-stream\nContent-Transfer-Encoding: base64\n\n'
           cat myattachment.bin | openssl base64
           echo '.'
        } | nc smtp.mydomain.org 25



        # telnet postfix_server 25

        220 smtp.yy.zz ESMTP
        helo me
        250 servernm.yy.zz
        MAIL FROM: <fromsms1@...>
        250 Ok
        RCPT TO: <mail@...>
        550 <mail@...>: Recipient address rejected: User unknown in relay
        recipient table
        RCPT TO: <postfix@...>
        550 <postfix@...>: Recipient address rejected: User unknown in relay
        recipient table
        DATA
        554 Error: no valid recipients


        How do I obtain a valid RCPT TO: address?


        TIA
        Roger
      • Roger Goh
        Just to add, I m not allowed to start up sendmail (as it s hardened for security reason), so editing sendmail.cf may not be an option. So I certainly need a
        Message 3 of 9 , Nov 28, 2011
        • 0 Attachment
          Just to add, I'm not allowed to start up sendmail (as it's hardened
          for security reason), so editing sendmail.cf may not be an option.

          So I certainly need a script/tool to do this forwarding to the relay
          /postfix server


          Roger

          On Tue, Nov 29, 2011 at 11:15 AM, Roger Goh <gproger@...> wrote:

          >
          > Script:
          > =====
          >
          >  {
          >     echo 'helo me'
          >     echo 'MAIL FROM:<you@...>'
          >     echo 'RCPT TO: <someone@...>'
          >     echo 'DATA'
          >     echo -e 'To:someone@...\nMIME-Version: 1.0
          >  (mime-construct 1.9)\nContent-Type:
          >  application/octet-stream\nContent-Transfer-Encoding: base64\n\n'
          >     cat myattachment.bin | openssl base64
          >     echo '.'
          >  } | nc smtp.mydomain.org 25
          >
          >
          >
          > # telnet postfix_server 25
          >
          > 220 smtp.yy.zz ESMTP
          > helo me
          > 250 servernm.yy.zz
          > MAIL FROM: <fromsms1@...>
          > 250 Ok
          > RCPT TO: <mail@...>
          > 550 <mail@...>: Recipient address rejected: User unknown in relay
          > recipient table
          > RCPT TO: <postfix@...>
          > 550 <postfix@...>: Recipient address rejected: User unknown in relay
          > recipient table
          > DATA
          > 554 Error: no valid recipients
          >
          >
          > How do I obtain a valid RCPT TO: address?
          >
          >
          > TIA
          > Roger
          >
        • Wietse Venema
          ... Use the POSTFIX sendmail command. Wietse
          Message 4 of 9 , Nov 29, 2011
          • 0 Attachment
            Roger Goh:
            > Just to add, I'm not allowed to start up sendmail (as it's hardened
            > for security reason), so editing sendmail.cf may not be an option.
            >
            > So I certainly need a script/tool to do this forwarding to the relay
            > /postfix server

            Use the POSTFIX sendmail command.

            Wietse
          • Jeroen Geilman
            ... ...why ? Are you using sendmail, or are you using postfix ? -- J.
            Message 5 of 9 , Dec 1, 2011
            • 0 Attachment
              On 2011-11-29 04:15, Roger Goh wrote:
              > Yes, understand the syntax/example mutt& nail that Jeroen&
              > Noel provided but sendmail.cf will need to be configured.

              ...why ?
              Are you using sendmail, or are you using postfix ?

              --
              J.
            • Roger Goh
              ... I need to send mails out from an RHES4.x box (which does not have Postfix installed & sendmail is not supposed to be started as it s hardened for security
              Message 6 of 9 , Dec 1, 2011
              • 0 Attachment
                >> Noel provided but sendmail.cf will need to be configured.
                > ...why ?
                > Are you using sendmail, or are you using postfix ?

                I need to send mails out from an RHES4.x box (which does
                not have Postfix installed & sendmail is not supposed to be
                started as it's hardened for security reason). This box is on
                the same subnet as a Postfix server. So I needed a way to
                route mails from this RHES4.x box via that Postfix server.

                My first attempt in using an MUA (a Perl script) from
                http://www.logix.cz/michal/devel/smtp-cli/ gave no joy.

                Now, someone has given me another MUA solution which
                doesn't require me to install any RPM package:
                Download & compile the tool below
                http://sourceforge.net/projects/msmtp/files/msmtp/1.4.26/
                to get the executable binary on the RHES4.x box & on this
                box, create .msmtprc file in the home directory of the user
                that needs to send email (in RHES4.x box) that has the lines:

                account postfix
                host smtp.mypostfix_domain.com
                from joe_smith@mypostfix_domain.com

                auth on
                user joe_smith@mypostfix_domain.com
                password secret


                Then I can use the following Shell script (with the compiled
                msmtp to send out mails from the RHES4.x box:
                { echo -e 'To:someone@...\nMIME-Version: 1.0
                (mime-construct 1.9)\nContent-Type:
                application/octet-stream\nContent-Transfer-Encoding: base64\n\n'
                cat myattachment.bin | openssl base64 } | msmtp --account=postfix

                joe_smith will be a dummy email account on the postfix
                so the password 'secret' will not be so much of a security
                issue.



                Roger
              • Jeroen Geilman
                ... So... what, exactly, is not working ? -- J.
                Message 7 of 9 , Dec 1, 2011
                • 0 Attachment
                  On 2011-12-01 14:53, Roger Goh wrote:
                  >>> Noel provided but sendmail.cf will need to be configured.
                  >> ...why ?
                  >> Are you using sendmail, or are you using postfix ?
                  > I need to send mails out from an RHES4.x box (which does
                  > not have Postfix installed& sendmail is not supposed to be
                  > started as it's hardened for security reason). This box is on
                  > the same subnet as a Postfix server. So I needed a way to
                  > route mails from this RHES4.x box via that Postfix server.
                  >
                  > My first attempt in using an MUA (a Perl script) from
                  > http://www.logix.cz/michal/devel/smtp-cli/ gave no joy.
                  >
                  > Now, someone has given me another MUA solution which
                  > doesn't require me to install any RPM package:
                  > Download& compile the tool below
                  > http://sourceforge.net/projects/msmtp/files/msmtp/1.4.26/
                  > to get the executable binary on the RHES4.x box& on this
                  > box, create .msmtprc file in the home directory of the user
                  > that needs to send email (in RHES4.x box) that has the lines:
                  >
                  > account postfix
                  > host smtp.mypostfix_domain.com
                  > from joe_smith@mypostfix_domain.com
                  >
                  > auth on
                  > user joe_smith@mypostfix_domain.com
                  > password secret
                  >
                  >
                  > Then I can use the following Shell script (with the compiled
                  > msmtp to send out mails from the RHES4.x box:
                  > { echo -e 'To:someone@...\nMIME-Version: 1.0
                  > (mime-construct 1.9)\nContent-Type:
                  > application/octet-stream\nContent-Transfer-Encoding: base64\n\n'
                  > cat myattachment.bin | openssl base64 } | msmtp --account=postfix
                  >
                  > joe_smith will be a dummy email account on the postfix
                  > so the password 'secret' will not be so much of a security
                  > issue.
                  >
                  >
                  >
                  > Roger


                  So... what, exactly, is not working ?



                  --
                  J.
                Your message has been successfully submitted and would be delivered to recipients shortly.