Traffic accidents cause great casualties and property losses all over the world. Thus, traffic safety is one of the very important topics in smart cities. One of the major causes of traffic accidents is bad driving behaviors. This paper proposes a smartphone-based IoT (Internet of Things) system to monitor driving behaviors by using a machine learning classifier. In this system, a smartphone is put into a car near the driver. A cloud server gets data from accelerators and GPS (Global Positioning System) sensors in the smartphone through a 4G/5G network. In the cloud server, an SVM (Support Vector Machine) classifier and a GPS speed-detecting algorithm are installed to identify abnormal driving behaviors and the instantaneous speed of the car. A user performance report is generated at the end of a journey. The report shows abnormal driving behaviors during the journey and information when the car is over the speed limit. We carried out some experiments and we found that the system can identify different abnormal driving behaviors and driving speed properly. Moreover, the system generated user performance reports properly.