Oh my goodness, poor you! What a horrible situation - gross to receive at the best (worst?!) of times, but from DP's best friend too, what on earth made him think it was a good idea?!
Ideally, I would want to tell DP, but it depends on what you mean by he's 'having an awful time just now' and how you think he'd react.
Sorry to ask, but was the text conversation you were having flirtatious in any way (even if it was, this obviously doesn't excuse his behaviour), or is he usually flirtatious with you in person? How often do you and/or DP see this guy? How close are they, how long have they been friends and how strong is their friendship - is it likely to withstand something like this? Does his friend have a partner? Sorry - so many questions!
In an ideal world, I would text him back saying something along the lines of "That was wildly inappropriate. I will be telling DP about this. I am now blocking your number. Never contact me again. You disgust me." I would then tell DP first thing in the morning and give him my phone so that he can see as much or as little as he likes and can see for himself that this was entirely one-sided and that the pics were totally unsolicited.
However, it very much depends on your answers to my earlier questions (please don't feel you have to answer them all - they're just things I would consider when making the decision).
If you feel that DP isn't strong enough to receive this information at the moment, then I would text his friend back with the message as before, then screen shot the conversation and save it on my phone but perhaps password protect it, so that if the time comes when you think DP can handle it and you feel you want to tell him, then you can show him the screen shots. I would delete the conversation then block him from being able to contact me.
As distasteful as it is, if you're not going to tell DP immediately, I really do think it's worth saving the screen shots so that you can prove everything to him if you need to. Perhaps even write a note on your phone explaining that you wanted to tell him immediately, but outlining the reasons why you felt it wasn't a good idea right now, then save this note in the same folder as the screen shots, so that if your DP did accidentally come across it one day, then he'll also see a dated explanatory note alongside it - rather than just finding a couple of photos of his best friend's junk on your phone!
I'm so sorry this has happened to you - it's such an invasion and so completely inappropriate. It sounds like something a pissed 17 year old might do if he wanted to make his girlfriend jealous (although I'm not even sure a drunk teenager would think sending a photo of his penis to anyone other than his girlfriend - even then, who on earth ever thinks it's a good idea to send these types of pictures, I've personally never met a photo-worthy 'pretty penis' - is a particularly great idea...) I hope you manage to settle on a solution you're comfortable with and that you're able to rid yourself of the images asap!
Sending you some mind-bleach @Tyrozet, good luck!