말하다 means when you express your thoughts, feelings, some facts, with words. You can also use 말하다 to ask a request.
이야기하다 means when you talk about stories, feelings or thoughts.
Use 말하다 when you talk to someone and 이야기하다 when you talk with someone.
- 내 생각을 친구에게 말해요.
- 내 생각을 친구와 함께 이야기해요.