It seems to me that it would be an incredibly dangerous job to go and meet the enemy's army?
It depended on which country the POW was from as well as which country the POW was being held by but generally, letters from and to POWs were usually sent through non-belligerent countries and humanitarian organizations such as Switzerland or the International Red Cross. Though it typically took months for letters to arrive as they weren't necessarily sent through the most direct mail route.
Typically POWs were allowed to send a limited number of postcards and letters a month back home in their native language, but were allowed to receive an unlimited number of pieces of mail and packages, though both incoming and outgoing mail were still subject to being censored or having contraband material being removed.
Article 36 of the 1929 Geneva Convention on Prisoners of War stipulated the following in regards to mail,
Each of the belligerents shall fix periodically the number of letters and postcards which prisoners of war of different categories shall be permitted to send per month, and shall notify that number to the other belligerent. These letters and cards shall be sent by post by the shortest route. They may not be delayed or withheld for disciplinary motives. Not later than one week after his arrival in camp, and similarly in case of sickness, each prisoner shall be enabled to send a postcard to his family informing them of his capture and the state of his health. The said postcards shall be forwarded as quickly as possible and shall not be delayed in any manner. As a general rule, the correspondence of prisoners shall be written in their native language. Belligerents may authorize correspondence in other languages.
Sources: Article 36 of the 1929 Geneva Convention on Prisoners of War
Sold blog and write up on Canadian held German POWs mail during WWII: https://powsincanada.wordpress.com/2014/07/11/kriegsgefangenenpost-prisoner-of-war-mail-part-i/