interactive SMTP command using telnet via a shell script

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I'm trying to access a SMTP remote server thru a remote shell using telnet and a command file
containing command to send to that SMTP server as seen on
https://tecadmin.net/ways-to-send-email-from-linux-command-line/#
(note: that on the above website this is done interactivly) but here I want to do that inside a
command file (Iv just copied the yellow/red (the uses input)) to the command file marked
<<<<<<<<< >>>>>>>>>



<<<<<<<<<
HELO yahoo.com
mail from: sender@tecadmin.net
rcpt to: myemail@mail.com
data



Hey
This is test email only



Thanks
.



quit











>











telnet IP smtp < command.txt



this always returns



Trying 1.1.65.49...
Connected to 1.1.65.49.
Escape character is '^]'.
Connection closed by foreign host.



immediatly



whereas when I do it interactily



<<<<<<<<<<<
perlhook@bbis:~/temp_25$ telnet 1.1.65.49 smtp
Trying 1.1.65.49...
Connected to 1.1.65.49.
Escape character is '^]'.
220 miraino-manabi.jp ESMTP Postfix
HELO yahoo.com
250 miraino-manabi.jp
mail from: sender@tecadmin.net
250 2.1.0 Ok
rcpt to: myemail@ymail.com
554 5.7.1 : Relay access denied
^]
telnet> quit













>













I get a return codes 220 250 554



I'v also tried inside a here doc shell script
<<<<<<<<<<
telnet 1.1.65.49 smtp <


Hey
This is test email only



Thanks
.



quit
END_SCRIPT












>












and get the same results.



How can I get around this and make the script act as is it was interactive ?



Thank's in advance









share







New contributor




user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.























    up vote
    0
    down vote

    favorite












    I'm trying to access a SMTP remote server thru a remote shell using telnet and a command file
    containing command to send to that SMTP server as seen on
    https://tecadmin.net/ways-to-send-email-from-linux-command-line/#
    (note: that on the above website this is done interactivly) but here I want to do that inside a
    command file (Iv just copied the yellow/red (the uses input)) to the command file marked
    <<<<<<<<< >>>>>>>>>



    <<<<<<<<<
    HELO yahoo.com
    mail from: sender@tecadmin.net
    rcpt to: myemail@mail.com
    data



    Hey
    This is test email only



    Thanks
    .



    quit











    >











    telnet IP smtp < command.txt



    this always returns



    Trying 1.1.65.49...
    Connected to 1.1.65.49.
    Escape character is '^]'.
    Connection closed by foreign host.



    immediatly



    whereas when I do it interactily



    <<<<<<<<<<<
    perlhook@bbis:~/temp_25$ telnet 1.1.65.49 smtp
    Trying 1.1.65.49...
    Connected to 1.1.65.49.
    Escape character is '^]'.
    220 miraino-manabi.jp ESMTP Postfix
    HELO yahoo.com
    250 miraino-manabi.jp
    mail from: sender@tecadmin.net
    250 2.1.0 Ok
    rcpt to: myemail@ymail.com
    554 5.7.1 : Relay access denied
    ^]
    telnet> quit













    >













    I get a return codes 220 250 554



    I'v also tried inside a here doc shell script
    <<<<<<<<<<
    telnet 1.1.65.49 smtp <


    Hey
    This is test email only



    Thanks
    .



    quit
    END_SCRIPT












    >












    and get the same results.



    How can I get around this and make the script act as is it was interactive ?



    Thank's in advance









    share







    New contributor




    user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.





















      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I'm trying to access a SMTP remote server thru a remote shell using telnet and a command file
      containing command to send to that SMTP server as seen on
      https://tecadmin.net/ways-to-send-email-from-linux-command-line/#
      (note: that on the above website this is done interactivly) but here I want to do that inside a
      command file (Iv just copied the yellow/red (the uses input)) to the command file marked
      <<<<<<<<< >>>>>>>>>



      <<<<<<<<<
      HELO yahoo.com
      mail from: sender@tecadmin.net
      rcpt to: myemail@mail.com
      data



      Hey
      This is test email only



      Thanks
      .



      quit











      >











      telnet IP smtp < command.txt



      this always returns



      Trying 1.1.65.49...
      Connected to 1.1.65.49.
      Escape character is '^]'.
      Connection closed by foreign host.



      immediatly



      whereas when I do it interactily



      <<<<<<<<<<<
      perlhook@bbis:~/temp_25$ telnet 1.1.65.49 smtp
      Trying 1.1.65.49...
      Connected to 1.1.65.49.
      Escape character is '^]'.
      220 miraino-manabi.jp ESMTP Postfix
      HELO yahoo.com
      250 miraino-manabi.jp
      mail from: sender@tecadmin.net
      250 2.1.0 Ok
      rcpt to: myemail@ymail.com
      554 5.7.1 : Relay access denied
      ^]
      telnet> quit













      >













      I get a return codes 220 250 554



      I'v also tried inside a here doc shell script
      <<<<<<<<<<
      telnet 1.1.65.49 smtp <


      Hey
      This is test email only



      Thanks
      .



      quit
      END_SCRIPT












      >












      and get the same results.



      How can I get around this and make the script act as is it was interactive ?



      Thank's in advance









      share







      New contributor




      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.











      I'm trying to access a SMTP remote server thru a remote shell using telnet and a command file
      containing command to send to that SMTP server as seen on
      https://tecadmin.net/ways-to-send-email-from-linux-command-line/#
      (note: that on the above website this is done interactivly) but here I want to do that inside a
      command file (Iv just copied the yellow/red (the uses input)) to the command file marked
      <<<<<<<<< >>>>>>>>>



      <<<<<<<<<
      HELO yahoo.com
      mail from: sender@tecadmin.net
      rcpt to: myemail@mail.com
      data



      Hey
      This is test email only



      Thanks
      .



      quit











      >











      telnet IP smtp < command.txt



      this always returns



      Trying 1.1.65.49...
      Connected to 1.1.65.49.
      Escape character is '^]'.
      Connection closed by foreign host.



      immediatly



      whereas when I do it interactily



      <<<<<<<<<<<
      perlhook@bbis:~/temp_25$ telnet 1.1.65.49 smtp
      Trying 1.1.65.49...
      Connected to 1.1.65.49.
      Escape character is '^]'.
      220 miraino-manabi.jp ESMTP Postfix
      HELO yahoo.com
      250 miraino-manabi.jp
      mail from: sender@tecadmin.net
      250 2.1.0 Ok
      rcpt to: myemail@ymail.com
      554 5.7.1 : Relay access denied
      ^]
      telnet> quit













      >













      I get a return codes 220 250 554



      I'v also tried inside a here doc shell script
      <<<<<<<<<<
      telnet 1.1.65.49 smtp <


      Hey
      This is test email only



      Thanks
      .



      quit
      END_SCRIPT












      >












      and get the same results.



      How can I get around this and make the script act as is it was interactive ?



      Thank's in advance







      shell-script smtp telnet interactive





      share







      New contributor




      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.










      share







      New contributor




      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.








      share



      share






      New contributor




      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.









      asked 9 mins ago









      user2901196

      1




      1




      New contributor




      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.





      New contributor





      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.






      user2901196 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.

























          active

          oldest

          votes











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );






          user2901196 is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476451%2finteractive-smtp-command-using-telnet-via-a-shell-script%23new-answer', 'question_page');

          );

          Post as a guest



































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          user2901196 is a new contributor. Be nice, and check out our Code of Conduct.









           

          draft saved


          draft discarded


















          user2901196 is a new contributor. Be nice, and check out our Code of Conduct.












          user2901196 is a new contributor. Be nice, and check out our Code of Conduct.











          user2901196 is a new contributor. Be nice, and check out our Code of Conduct.













           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f476451%2finteractive-smtp-command-using-telnet-via-a-shell-script%23new-answer', 'question_page');

          );

          Post as a guest













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay