I was under the impression that when we send mail to any domain (i.e. xyz@gmail.com) from another domain (i.e. abc@yahoo.com), the Yahoo server would automatically get the SMTP host for gmail.com from the Web.
Now I am doing my application integration with James mail server and I have created a dummy domain on James (i.e. fdg@myJamesMail.com) and I gave the mapping of myJamesMail.com in my host file. But still I need to mention the SMTP host explicitly.
Is it really required?
When you’re sending an email programmatically, you have to state your local SMTP server – the one which will accept mails from you, and propagate them to the target server.
If you have a “thick” mail client program, this is part of configuration – and obviously if you’re using web mail of some description (e.g. gmail) it’s handled within the web side of things. That’s why you don’t need to worry about it as a user in that situation – but as a programmer you need to know which host to make the connection to, which is meant to be an SMTP server which trusts the sender, not an SMTP server associated with the recipient.