The Hammers and Mainz will meet on Tuesday 31st July at Kufstein Arnea in Tyrol in Austria.
The 2018 Betway Cup match will kick off at 18:30 CEST (17:30 BST).
The 2018 Betway Cup will be the fourth time the Hammers have played the pre-season competition, facing Werder Bremen at the Boleyn Ground in the inaugural fixture in 2015. The Hammers then played against Italian giants Juventus in a thrilling first match at London Stadium at the start of the 2016/17 season. A two-legged tie with Werder Bremen in Germany followed last summer, with a goal from Marko Arnautovic on his full debut the highlight of the second contest.
West Ham and Mainz last met in a pre-season fixture in the summer of 2013, a game in which the Irons scored through Academy graduate Joe Cole.