Test SMTP Authentication using Telnet

After long time, started to post blogs.

In this blog I am explaining to test our SMTP authentication using Telnet command.

Before we start, lets convert our username and password into base64 format

Connect our mail server with below command

praveen@praveen:~$ telnet {YourMailServer} {PORT}
(e.g)
praveen@praveen:~$ telnet youmailserver.com 587

If you run the above command you will be getting response like below

Trying IP_OF_YOUR_MAIL_SERVER...
Connected to youmailserver.com.
Escape character is '^]'.
220 youmailserver.com ESMTP ready.

Then run the below command

EHLO youmailserver.com

You will get response as below

250-youmailserver.com Hello youmailserver.com [IP_OF_YOUR_MAIL_SERVER]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP

Then type as below to initiate login

AUTH LOGIN

You will get below response

334 VXNlcm5hbWU6

If you base64 decode “VXNlcm5hbWU6” you can see “Username:

In this step you need to put your base64 converted username as below

eW91cnVzZXJuYW1l

Then it will ask for the password as below

334 UGFzc3dvcmQ6

Type your password with base64 converted

eW91cnBhc3N3b3Jk

If the username and password what you’ve provided is valid then it will throw response like this.

235 Authentication succeeded

The complete flow will look like this

praveen@praveen:~$ telnet youmailserver.com 587
Trying IP_OF_YOUR_MAIL_SERVER...
Connected to youmailserver.com.
Escape character is '^]'.
220 youmailserver.com ESMTP ready.
EHLO youmailserver.com
250-youmailserver.com Hello youmailserver.com [IP_OF_YOUR_MAIL_SERVER]
250-SIZE 52428800
250-8BITMIME
250-PIPELINING
250-AUTH PLAIN LOGIN
250-STARTTLS
250 HELP
AUTH LOGIN     
334 VXNlcm5hbWU6
eW91cnVzZXJuYW1l
334 UGFzc3dvcmQ6
eW91cnBhc3N3b3Jk
235 Authentication succeeded

 

Using Selectric Js with Jquery Validator Js

I have using normal form. And I want to change the select box style. So I have found Selectric Js Plugin javascript.

And I thought that the validation of the form will happen in the client side means that will looks much easier. So I have downloaded Jquery Validator Plugin. Both are working fine.

After that I have found a problem with form validation. When I try to use selectric js with jquery validator means the selectric will hide the default selectbox. So the error message of the select box won’t appear in the frond end. I have searched through the internet. And I have found an solution from selectric issues page.

Here is the Selectric Issue 32. In that lcdsantos has give a solution for the problem.

Here is the solution I got.

$('form').validate({
    ignore: ':hidden:not(select)',
    errorPlacement: function(error, element) {
        // check if element has Selectric initialized on it
        var data = element.data('selectric');
        error.appendTo( data ? element.closest( '.' + data.classes.wrapper ).parent() : element.parent() );
    },
    name: {
      required: true,
    },
    email: {
      required: true,
      email: true
    },
    country: {
      required: true
    }
});

Wow, This will get the error for the select box.

This will trigger manual error placement and place the error after the selectric list box.

But this also has problem. The problem is when we change the selectric box value the error is not hiding. After searching related this problem I have found another solution.

The solution is,
jQuery Selectric (select replacement) validation.

In this solution Sparky saying that to write a custom handler that will trigger validation on the hidden element programmatically whenever its value changes.

(e.g)

$('select[name="mySelect"]').on('change', function() { // fires when the value changes
    $(this).valid(); // trigger validation on hidden select
});

So the final solution would be like this

$('form').validate({
    ignore: ':hidden:not(select)',
    errorPlacement: function(error, element) {
        // check if element has Selectric initialized on it
        var data = element.data('selectric');
        error.appendTo( data ? element.closest( '.' + data.classes.wrapper ).parent() : element.parent() );
    },
    name: {
      required: true,
    },
    email: {
      required: true,
      email: true
    },
    country: {
      required: true
    }
});
$('select[name="country"]').on('change', function() { // fires when the value changes
    $(this).valid(); // trigger validation on hidden select
});

Now my code working fine. 🙂

Laravel 5 Basic CRUD Application – Part 2 (Setup)

Laravel 5 Basic CRUD Application – Part 1

In part 1 we have seen that how to install laravel.

Now we have mycrud directory in ‘/var/www/html/’ directory.

Now we are going to setup database for laravel. To do this you have to setup the db name and user name, password in the env file. This env file located in laravel root directory. In our example the file is in ‘/var/www/html/mycrud/.env’

“Note: the .env file is hidden. So make sure that you have viewing hidden files. If no means just press

“CTRS + H” to view hidden files. And if you don’t have hidden files means just simply copy and paste .env.example file and rename it to .env.

Now edit the .env file, you can see the following lines in the file.

DB_HOST=localhost //Host 
DB_DATABASE=mycrud //DB name 
DB_USERNAME=root //Username 
DB_PASSWORD=root //Password 

The Default database for Larvel is MySql. If you are not using mysql means just mycrud/config/database.php file and find the below line

'default' => 'mysql',

Change mysql into whatever you want. If you don’t know about the database list means you can scroll down the database.php file, now you can see ‘connections‘ array. Inside of connections array you can see databases list with configuration.

That’s all. The basic setup for laravel is completed. See you in Part 3.

With Regards,
Praveen Srinivasan

Laravel 5 Basic CRUD Application – Part 1 (Installation)

Laravel is the very powerful framework for php web application.

Installation

Before starting new project you need Composer to install required dependencies. This helps you to download laravel dependencies.
To install Composer you need php5-curl. To install curl simply run the following command.

$ sudo apt-get install php5 git php5-curl

After successful installation of curl you can simply run the following command to download the composer.

$ curl -sS https://getcomposer.org/installer | php

Now you need to set path environment variable for composer. So that you can simply access composer by simply typing composer

Run the following command to set environment variable for composer

$ export PATH="$PATH:~/.composer/vendor/bin"

Now you can download laravel installer using composer. The below command will download the laravel installer.

composer global require "laravel/installer=~1.1"

That’s all..! All are set.

Now create a basic project by simply typing the following command

laravel new mycrud

now the new project mycrud was created in the directory. Be sure your project directory is in ‘/var/www/html’

Laravel 5 Basic CRUD Application – Part 2 (Setup)

Scrap web content using Python Beautifulsoup

Hello to all,

Now I am sharing about Python BeautifulSoup package which helps to scrap html content from the web.
You can install BeautifulSoup by pip using the following command.

$ sudo pip install beautifulsoup4


the following simple program will scraps all links from index.html file

index.html

<html>
<headl>
<title> Simple BeautifulSoup <title>
<body>
<a href="http://google.com">Click</a>
</html>



test.py

from bs4 import BeautifulSoup
 
soup = BeautifulSoup(open("./index.html"))
 
for anchor in soup.find_all('a'):
    print(anchor.get('href', '/'))


Save the both file into a single folder. Then run the python command “python test.py“. The Beautifulsoup will open the index.html file and finds all a (anchor) tags in the html file. Then it’ll get the href in the anchor tag, after that it’ll print the href’s text.
The output will look like this.

$ python test.py
http://google.com

And you can also scrap content from the web. The following is my code which gets all link from a website.


flipkart_href.py

from bs4 import BeautifulSoup
import urllib2

url = "http://flipkart.com"
page = urllib2.urlopen(url)
soup = BeautifulSoup(page)
links = soup.find_all("a")

for link in links:
    address = "flipkart.com"+link.get('href')
    print address+ '\n'



Explanation->

  • url = http://flipkart.com -> This line stores the url.
  • page = urllib2.urlopen(url) -> The urllib2 will open the url from the web and stores it into page variable
  • soup = BeautifulSoup(page) -> The BeautifulSoup function will stores the content of the webpage into soup variable
  • links = soup.find_all(“a”) -> The soup.find_all function will get all “a” anchor tags into links varible
  • for link in links: -> This for loop will stores all the links variable into link variable for looping process.
  • address = “flipkart.com”+link.get(‘href’) -> The link.get(‘href’) function will get links from the anchor tag, and stores it into address variable.
  • print address -> This will prints the address finally.
  • Similarly we can scrap anything from web with the use of python BeautifulSoup.

    Any queries with BeautifulSoup, please comment.

    With Regards,
    S. Praveen

    Create a Repository in GitHub

    Hello to all,

    Now I am going to share how to create a Repository in GitHub account, and how to add an initial commit into that.
    First we need to create an new account in GitHub
    Then you have to install Git on your Linux Desktop using the following command.

    $ sudo apt-get install git-core

    Create a new repository and push data using command line


    Just do the following commands

    $ touch README.md
    $ git init
    $ git add README.md
    $ git commit -m "first commit"
    $ git remote add origin https://github.com/Your-User-Name/Your-Repository-Name.git
    $ git push -u origin master


  • The first “touch README.md” command is used to create an README file for your Repository.
  • And the second “git init” command is used to initialize an empty Repository in the current working directory of your local computer.
  • The third “git commig -m ‘first commit'” command is used to changes records to the repository.
  • The fourth “git remote add origin ”’github.com/Your-User-Name/Your-Repository-Name.git”'” command adds a new remote repository of your project
  • The final “git push -u origin master” commands pushes your new branches and data to a remote repository

    If you have any doubts means got the the Try GitHub link. It has a live demo about github.com

    With Regards,
    S. Praveen

  • Convert Tamil Unicode values into Tamil strings

    Hi here I shared How to convert Tamil Unicode values into Tamil strings in python.

    Just we need to store the values in Array as follows. Here i am created an array variable which stores my all the Unicode Tamil values.

    Run the following code in Python interactive shell

    >>>mystring = [u'\u0bb5', u'\u0ba3' u'\u0b95' u'\u0bcd' u'\u0b95' u'\u0bae' u'\u0bcd']


    This will stores all the Unicode values into the “mystring” array variable.

    And now just do the following code

    >>>print u''.join(mystring)
    வணக்கம்


    This will prints the converted Unicode Tamil characters.

    With Regards
    S. Praveen

    FSFTN Project 2014 Meet

    I start my Font converter project. I start my project with the help of FSFTN.

    We did the meeting about Project14. We discussed about our project. And Mr. ARUN helped me to start my project. He guides me to learn about Unicode. Today I has a second review of my project. So I am preparing myself for that.

    The following is the abstract of my project which is submitted at my first review.

    FONT CONVERTER FOR TAMILABSTRACT
    The project entitled “FONT CONVERTER FOR TAMIL” place a major role in Office productivity tool. This project provides a proper solution to the ‘Tamil’ publishing industry. The main aim of this project is to convert Tamil fonts into Unicode which is commonly supported by all systems and mobile devices. If this application is developed, there is no need of installing Tamil fonts to view Tamil characters.
    There are lot of Tamil fonts in TSCII and ASCII format. For Example: TAM, TAB, Vanavil, Bamini, Indoword, Softview, Kabilan, Kaniyam, shri TAM, shri Lipi, Ilango, Mayilai, Anu, Senthamizh, Vikadan, Indoweb, TSC, Thinathanthi, Thinaboomi, Dinamani etc,.. These are used in DTP centers.
    There are tons of documents generated in these fonts. To view them, we need to install these fonts locally. These documents should be converted to Unicode so that anyone can view them without installing any special fonts. Some of its features are covered by online application.

    EXISTING SYSTEM
    NHM converter is an online / offline service which does some of these features. But it does not cover all the Tamil fonts available in Tamil Nadu. Already some of other applications (Azhagi, Tavultesoft Keyman, E-kalappai) available in Windows operating system and it does not cover full features and did not support all commonly used Tamil fonts.
    The proposed system of our project is to create an Application under GPL V3 license , which is free , open and can be used independent of OS platform.

    ADVANTAGES
    • Providing a simple user interface.
    • It is Open Source Application (GNU/Linux)
    • We don’t have the need of installing Tamil fonts.
    • We can view the Tamil fonts in all the computers and Mobile devices and Tablets.
    • It is an offline application.

    Kivy – Open source Python library

    I have started my final project. So that i searched which framework is best for doing my project. I asked my senior Shrinivasan from Kanchilug. He told me to use Kivy python library. I don’t know about kivy, i search this term on internet. Here i shared my knowledge about Kivy.
    Kivy – is an Open source Python library for rapid development of applications that make use of innovative user interfaces, such as multi-touch apps.

    I think many of the GUI frameworks available in python like PyGTK, PyQT, WXPython, TKinter etc,.. Then what is the advantage of using Kivy?

    I asked this in IRC chat. My friend simply said the following answer.

    1. Do you want to create a functional GUI with the least work? TKinter.
    2. Do you want to create something that looks great in Linux? PyGTK.
    3. Something that looks as good as possible across all platforms? PyQT.
    4. Something with all the above and multitouch? use Kivy.

    Advantages:

    1. Cross platform
    Kivy runs on Linux, Windows, OS X, Android and iOS. You can run the same code on all supported platforms.
    It can use natively most inputs, protocols and devices including WM_Touch, WM_Pen, Mac OS X Trackpad and Magic Mouse, Mtdev, Linux Kernel HID, TUIO. A multi-touch mouse simulator is included

    2. Business Friendly
    Kivy is 100% free to use, under an MIT license (for 1.8 and 1.7.2), and LGPL 3 for the previous versions. The toolkit is professionally developed, backed and used. You can use it in a commercial product.
    The framework is stable and has a well documented API, plus a programming guide to help you get started.

    You can get all the above informations from kivy.org

    Kivy installation Ubuntu

    I am using Ubuntu 12.04, Here i am sharing installation methods for Ubuntu 12.04 and other versions.

    Step 1:

    The above command will asks you to install “pip” command if you don’t have it.
    So first we need to install pip command. The following command is used to install pip.
    First we need PIP command for installing Kivy. So first done the following command

    $ sudo apt-get install python-pip



    For Ubuntu 12.04 follow this command, this will install all necessary packages.

    $ sudo apt-get install python-setuptools python-pygame python-opengl \
      python-gst0.10 python-enchant gstreamer0.10-plugins-good python-dev \
      build-essential libgl1-mesa-dev-lts-quantal libgles2-mesa-dev-lts-quantal\
      python-pip


    If you are using other versions of Ubuntu, do the follow command:

    $ sudo apt-get install python-setuptools python-pygame python-opengl \
      python-gst0.10 python-enchant gstreamer0.10-plugins-good python-dev \
      build-essential libgl1-mesa-dev libgles2-mesa-dev zlib1g-dev python-pip


    Step 2:

    Kivy requires a recent version of Cython.
    The following command is used to Upgrade Cython.

    $ sudo pip install --upgrade cython


    Tutorials

    The following official link helps you working with Kivy framework.
    Click here for “Tutorials”

    And the following link will helps you to download Kivy Documentation as PDF
    Download Documentation.

    With Regards
    S. Praveen