Alex Neil's men were drawn against the League Two outfit during Tuesday morning's draw.
The Stags finished 21st in the bottom flight of English football last season and are managed by John Dempster
The tie will likely take place on August 29 - two weeks before the Championship season is due to start.
Originally all first-round games in the Carabao Cup were due to take place on the weekend of September 5, but any ties involving Championship sides have been put back a week to avoid a clash with the upcoming international break.
North End will be hoping for a good run in the competition similar to last season.
After a 4-0 victory over Bradford City at Valley Parade in the opening round and a penalty shoot-out win over Hull, following a 2-2 draw at Deepdale, PNE were handed a plum draw in the third round when they were paired with Manchester City, who were at the time the current premier League champions.
The Lilywhites produced a spirited display against City at Deepdale, but it was the visitors who progressed courtesy of a 3-0 victory thanks to goals from Raheem Sterling, Gabriel Jesus and a Ryan Ledson own goal.
Pep Guardiola's men went on to lift the cup, beating Aston Villa 2-1 at Wembley.
All Premier League teams enter into the competition, barring teams involved in Europe, at the second round stage.
Watford and Bournemouth - relegated from the top flight last season - also enter the tournament in the second round.