Stochastic maximum principle for problems with delay with dependence on the past through general measures