See this method .
In your case it will be V2 folder for Mac OS Yosemite .
Transfer mail data from one machine to another .
Take back up of all mails in V 5 folder : Method to copy mails in V 5 folder .
Click on Go on top menu bar , hold option key click on > library > select mail folder > right click on mail folder there itself > click on copy mail > right click on extreme right hand side in column B , that is below persistence info.plist > click on paste item .
Entire mails are copied to V 5 folder .
Note : For Mac OS High Sierra the folder will be V 5 , For Mac OS Sierra the folder will be V4 , For El Capitan - the folder will be V 3 , and for OSX Yosemite the folder will be V2
Take a USB stick and copy V 5 folder into it , once it is copied right click on the USB stick and eject it .
Insert the USB stick in the second machine .
Configure new IMAP account in another machine , go to top menu bar , file > import mail boxes > import data from > select apple mail > click on continue > select the back drop folder then choose new .
When new IMAP account is opened , a new folder with all mails will appear in the mail side bar .You can rename the folder .