Help with selling iMac...

Wonder if anyone can help me out. I am selling my old 2007 iMac with El Capitan on it. I just tried to erase the HD on it, and reinstall a fresh OS. When I get to the install prompts, it tells me to sign in using my apple ID to download El Capitan (I do), It goes through and prompts me that the item is not available, try again, I tried it again, again and again, still nothing. It keeps popping up that message. I have tried a search, but most of the threads drop off from the original poster, and never tells how its done.
Does anyone know how I would proceed to erase this iMac so I can sell it ? I can use a backup to restore it, but that does not help me. I want to get rid of everything, so i can sell it.

Download the El Capitan installer from the App Store. You can do that on another Mac, if you like.
The installer will automatically start when the download is complete. You can quit the installer, because you want to make a separate installer from that.
Make a bootable USB stick from that downloaded app. Search for "Create bootable El Capitan installer", or just use the good app DiskmakerX to easily make a bootable USB stick for El Capitan.
When you boot to that stick, you won't get asked for your AppleID when you run the installer.
Install, and on the final restart, the new user setup will appear. Quit that new user setup, and your iMac will shutdown, ready for the new user when it is started next time.
I would include the USB stick when you sell the iMac, as a bonus. But, I don't think any Mac, new or used, should be sold without reinstall media.
Newer Macs can install OS X over the internet, but I don't think that's enough. The local installer makes life simpler, I think. (you don't even NEED an internet connection to install that way!)

MacRumors attracts a broad audience
of both consumers and professionals interested in
the latest technologies and products. We also boast an active community focused on
purchasing decisions and technical aspects of the iPhone, iPod, iPad, and Mac platforms.