He was born at Portadown, Ireland on 20 February 1835, the son of a WM businessman associated with distilleries, a flour mill and the linen trade. At the age of 10 he was sent to the WM Grammar School (later Queen's College), Taunton, but transferred after one term to the WM Connexional School (now Wesley College), Dublin. He graduated from Queen's College, Belfast in 1853, with a postgraduate scholarship in modern languages. In 1854 he was nominated by the College Council for a post in the consular service in China and sailed for Hong Kong. In 1859, with the permission of the British government, he resigned from his consular post in Ningpo to become an official of the Chinese government. He became Deputy Commissioner in Canton and later Commissioner in Shanghai. In 1863 he was appointed Inspector General of the Chinese Imperial Maritime Customs which, by the end of the century was running the Chinese Imperial Postal Service. From 1864 until his retirement in 1908 he was based in Peking and was a key figure in the modernisation of China.
In 1866 he married Hester Jane Bredon of Portadown, but from 1881 his wife and family lived in England, revisiting China in 1905. He himself revisited Europe only twice, in 1866 and 1874. In 1866 he was accompanied by three 'wards', now believed to have been his illegitimate children, who were placed with foster parents. His home was ransacked and destroyed in the Boxer Rising of 1899-1900, but he survived despite an announcement of his death in The Times of 17 July 1900. Following the Rising he observed that missionaries had generally shown themselves to be 'plucky and self-sacrificing'. They needed to 'live down their persecution [and] only in the last resort seek the assistance of the Legations,' and to show respect for Chinese sensitivities and customs.
Well grounded in conversational and classical Chinese, he earned a reputation as a skilled negotiator with a flair for detail. In 1874 he described himself as 'a safe ... hard-working, modestly gifted, many-sided, equal-tempered, and inwardly god-fearing & heaven-seeking man.' Many honours were showered on him during his career, including the KCMG (1882) and GCMG (1889), a baronetcy in 1893 and in France the order of the Légion d'honneur (1885). The Irish Christian Advocate occasionally referred to his achievements and to the many Chinese and European honours bestowed on him.
He retired in 1908 and died on 20 September 1911, being buried at Bisham, Berks. A stamp commemorating the 150th anniversary of his birth was issued in Taiwan in 1985.
'Inspector-General of the Chinese Maritime Customs, Founder of the Chinese Lighthouse Service, Organizer and Administator of the National Post Office, Trusted Counsellor of the Chinese Government, True Friend of the Chinese People, Modest, Patient, Sagacious, and Resolute, He overcame formidable Obstacles, and Accomplished a work of Great Beneficence for China and the World.'
(Inscription on his statue in Shanghai)