How to add custom header when composing mails?

UserHeaders

For Apple's Mail.app, you can use the default UserHeaders to provide a dictionary of key value pairs to insert into the headers of outgoing e-mails.

To set the Disposition-Notification-To header to email@address the following command can be used:

 defaults write ~/Library/Containers/com.apple.mail/Data/Library/Preferences/com.apple.mail.plist UserHeaders '{"Disposition-Notification-To" = "email@address"; }'

On macOS 10.14, you will need to grant Terminal.app the Full Disk Access right in System Preferences.app > Privacy & Security before issuing the above command.

See Mail Receipt for an example of this default and notes about its application.