Boeing Co. has fired a midlevel executive in charge of pilots who exchanged internal emails that have embarrassed the aerospace company as it struggles to get the 737 MAX jetliner flying again, according to people familiar with the matter.

The ouster of the executive, Keith Cooper, follows the disclosures of the messages between two Boeing pilots that prompted concerns among federal lawmakers and regulators that some of the company’s employees took a cavalier attitude toward safety and honest communication with airline customers.

The messages also involved other Boeing employees.

Mr. Cooper was a vice president for training and professional services in Boeing’s global-services division, the people familiar with the matter said. His departure hasn’t been previously reported.

Mr. Cooper couldn’t be reached for comment. Mr. Cooper departed the company within the past couple of months, one of these people said.