Does this code has a Limitation of just sending emails from the same account like we can only send emails from one gmail account to another ?
or can we send emails from gmail to live/yahoo/webmailmail accounts too?
You can send email to users in the domain of the email server. If you nslookup gmail.com, you can send to about any existing user that has a gmail account, as in email@example.com. If you want to send to a firstname.lastname@example.org for example, you would need to nslookup yahoo.com to find the mail exchanger that will take email for yahoo.com.
The only check of the sender email address I ever see (besides the ip range by companies like Spamhaus) is the domain of the sender must be valid. If that is malformed or does not resolve, the email server may reject your email.
edit: I forgot to mention one annoying feature about these commercial email servers like gmail. They will only take so many emails per hour to the same destination address (and it isn't that many), then they will start rejecting your email temporarily, up to a few hours. It is actually a "not now, come back later" message. :(