Question: My employer offers an ESPP with the following details:

* 15% discount
* Max contribution is 15% of base salary
* Purchase transaction occurs on the last business day of the month
* Transaction settles 3 days after purchase
* No obligation to hold the stock for minimum duration
* No restrictions on sell timing (except during earnings lock-out period)
* Brokerage fees
	+ $0.05 per share sold (approximately 0.08% of the stock price today)
	+ $0 per share bought

Given these parameters...

What is the safest way to play the ESPP?

What is (likely) the most lucrative way to play the ESPP?

Assume I contribute the maximum amount allowable.
Assume I can hold the stock for up to you year before I may need to cash it out.

Answer: 
A 15% discount is a 17.6% return. (100/85 = 1.176). For a holding period that's an average 15.5 days, a half month. It would be silly to compound this over a year as the numbers are limited. 

The safest way to do this is to sell the day you are permitted. In effect, you are betting, 12 times a year, that the stock won't drop 15% in 3 days. You can pull data going back decades, or as long as your company has been public, and run a spreadsheet to see how many times, if at all, the stock has seen this kind of volatility over 3 day periods. Even for volatile stocks, a 15% move is pretty large, you're likely to find your stock doing this less than once per year. It's also safest to not accumulate too many shares of your company for multiple reasons, having to do with risk spreading, diversification, etc. 

2 additional points - 

the Brexit just caused the S&P to drop 4% over the last 3 days trading. This was a major world event, but, on average we are down 4%. One would have to be very unlucky to have their stock drop 15% over the specific 3 days we are discussing. 

The dollars at risk are minimal. Say you make $120K/yr. $10K/month. 15% of this is $1500 and you are buying $1765 worth of stock. The gains, on average are expected to be $265/mo. Doesn't seem like too much, but it's $3180 over a years' time. $3180 in profit for a maximum $1500 at risk at any month's cycle.
Short answer is to put the max 15% contribution into your ESPP.

Long answer is that since you want to be saving as much as you can anyway, this is a great way to force you to do it, and pick up at least a 15% return every six months (or however often your plan makes a purchase). I say at least because sometimes an ESPP will give you the lower of the beginning or end period stock price, and then a 15% discount off of that (but check the details of your plan). If you feel like your company's stock is a good long term investment, then hold onto the shares when purchased. Otherwise sell as soon as you get them, and bank that 15% return.