What is the php code to append class="external" to links that are posted and are not the domain.

For example my site is www.mysite.com and you post a link to www.mysite.com/news and a link to www.yoursite.com

How do I set it so only non "mysite.com" links have the class specified?