Get your visa beforehand
You must have a sponsor in Iran who can provide a Letter of Invitation before applying for an Iran visa. Once you have received the Letter of Invitation, you can submit it together with the necessary papers to an Iranian Embassy or Consulate in your country. If you are visiting Iran for tourism purposes, you must contact a travel agent or a friend or relative who will welcome you. If you are traveling on business, the firm you are visiting can provide you with an invitation letter.
In Iran, the travel agency, host, or corporation will file an application with the Iranian Ministry of Foreign Affairs (MFA). If your application is approved, you will be sent a visa code, which you must provide to the Iran Embassy/Consulate together with any other needed papers.
While citizens of some countries, such as the United States and the United Kingdom, must get visas in advance, others are part of the 'visa on arrival program and can receive one at major city airports. However, the procedure is not quick, and after traveling, you'll undoubtedly be eager to begin your Iran experience rather than sit about at the airport. Furthermore, there is a lot of disinformation on the internet, so you should apply for your visa ahead of time to avoid any errors.