This work develops a comprehensive optimal speed control framework for connected and autonomous electric vehicles considering both battery aging effects and regenerative braking limits. With the battery aging consideration, the energy benefits can be achieved together with a satisfactory battery life. The regenerative braking limits ensure the optimal control law is realistic and can be implemented in practice (e.g. there should be no regen when battery is almost full). The target vehicle intelligently controls the vehicle speed and car-following distance based on predicted traffic conditions using real-time information enabled by connectivity. The traffic prediction is based on a traffic flow model and can be implemented in a mixed-traffic scenario where both connected vehicles and non-connected vehicles share the road. The optimal control problem is formulated, simplified and discretized with minimal computational burden. It can be solved in real-time using an efficient nonlinear programming solver and is implemented in the model predictive control (MPC) fashion. The average computational time of the optimization is 0.54 seconds for a 15-second prediction horizon. A representative traffic scenario is evaluated in simulation where the target vehicle follows a vehicle platoon with 50% penetration rate of connectivity to pass a signalized roadway. The results show that 9.1% energy benefits can be obtained. The performance is satisfactory compared to 14.3% benefits with perfect traffic prediction.