Wednesday, October 29, 2014

User nc to send smtp message in centos

nc is a handy tool in unix to test network connection and we can use it
to write script to send smtp message as well. It is useful when we
implement some kind of server monitoring scripts and want to send out
alarm messages.

In the example below, we use 'nc' to connect smtp-server at port 25 to
send out contents in email-msg.txt

#nc smtp-server 25 < email-msg.txt

The email-msg.txt contains the below commands to form the smtp dialogue.

#cat email-msg.txt
HELO my-server
MAIL FROM:<sender@domain1.com>
RCPT TO:<receiver@domain2.com>
DATA
Subject:This is a sample subject
This is a sample mnessage body
.
QUIT

Note the last line of the message body is a line starting with '.'.

Another point to note is that if we create the email-msg.txt in unix
environment, we probably need to ensure each line ends by CRLF rather
than just a line feed.

To do so, we can simply use the unix2dos command:

#unix2dos email-msg.txt

24 comments:

  1. Thanks for sharing, nice post! Post really provice useful information!

    Giaonhan247 chuyên dịch vụ mua đồng hồ amazon với chia sẻ kinh nghiệm mua hàng trên Amazon và giải đáp mua hàng trên Amazon có đảm bảo không cũng như chia sẻ cách mua hàng trên ebay giúp các bạn mua hàng trên amazon vietnam uy tín nhất.

    ReplyDelete
  2. Hi, I do believe this is a great blog. I stumbledupon it ;) I'm going to come back yet again since i have saved as a favorite it. Money and freedom is the greatest way to change, may you be rich and continue to help others. aol mail sign in

    ReplyDelete
  3. Nice article, Which you have shared here about the SMTP. Your article is very informative and useful for those who are interested to know more about the Reliable SMTP Server. Thanks for sharing this article here.

    ReplyDelete
  4. What a Great post is this! I like this. It's awesome. I bookmark this page. And also told my friends to Book mark this. It can help everyone. Thanks for this post.
    To know more like this post just click here Best Vacuumc

    ReplyDelete
  5. Hello Sir,
    As a blog reader & writer you shared nice information this is very Usefull to us. Thank you.
    Looking for more best Achhamall deals !! Visit : achhamall (dot) com
    Shop your Online Digital Electronic Products. Invest in a good quality Product & get Best offers. shop now & Enjoy Free Shipping across India. our blog www.achhamall.blogspot.com kindly follow & like the post & comments.

    ReplyDelete
  6. For a long time me & my friend were searching for informative blogs, but now I am on the
    right place guys, you have made a room in my heart! i have already bookmarking this sites.
    i will back again. i truly motivated by you from blogging.Social Profile

    ReplyDelete
  7. This comment has been removed by the author.

    ReplyDelete
  8. Thanks for sharing this amazing blog.It is really an informative post, NECO QUESTION AND ANSWER EXPO 2019

    ReplyDelete
  9. Technosizzle is the hub of unlimited games reviews, games tricks and much more. Subscribe us for more and latest games on a daily basis. Technosizzle

    ReplyDelete
  10. This comment has been removed by the author.

    ReplyDelete


  11. Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!

    BIG DATA COURSE IN MALAYSIA

    ReplyDelete
  12. ou will get an introduction to the Python programming language and understand the importance of it. How to download and work with Python along with all the basics of Anaconda will be taught. You will also get a clear idea of downloading the various Python libraries and how to use them.
    Topics
    About ExcelR Solutions and Innodatatics
    Do's and Don’ts as a participant
    Introduction to Python
    Installation of Anaconda Python
    Difference between Python2 and Python3
    Python Environment
    Operators
    Identifiers
    Exception Handling (Error Handling)
    Excelr Solutions

    ReplyDelete
  13. :You will get an introduction to the Python programming language and understand the importance of it. How to download and work with Python along with all the basics of Anaconda will be taught. You will also get a clear idea of downloading the various Python libraries and how to use them.
    Topics
    About Excelr Solutions and Innodatatics
    Introduction to Python
    Installation of Anaconda Python
    Difference between Python2 and Python3
    Python Environment
    Operators
    Identifiers
    Exception Handling (Error Handling)

    [url=https://www.excelr.com/data-science-certification-course-training-in-singapore]Excelr Solutions[/url]

    ReplyDelete
  14. This is a very informative article for us. Really this is an amazing and helpful article. I’m Always get the new and latest article from this site and I like its very much .If you can get more another casino operated information and 카지노사이it’s helful.

    ReplyDelete
  15. Thank you for providing meaningful information, and if you need any help regarding cheap web hosting pakistan then come and visit us!

    ReplyDelete
  16. Thanks for sharing knowledge
    https://www.bigworld4u.com

    ReplyDelete
  17. Thank you for providing meaningful information, and if you need any help regarding Sarkari Job. in india then come and visit us!

    ReplyDelete
  18. Such a great informative post.. Really nice it for seo.. Thank you for sharing this with us. Keep posting!

    Search and Rescue Equipment

    ReplyDelete
  19. I love your article so much. Good job
    ExcelR is a global leader delivering a wide gamut of management and technical training over 40 countries. We are a trusted training delivery partner of 350+ corporate clients and universities across the globe with 28,000+ professionals trained across various courses. With over 20 Franchise partners all over the world, ExcelR helps individuals and organisations by providing courses based on practical knowledge and theoretical concepts.

    Excelr Solutions

    ReplyDelete