Okay, first, STOP.
Take a look at the script.
Run through it.
Tell me, of all the lines, how many do you understand. Other than print statements, how many could you change and know exactly what you were doing?
Are you asking us for help because:
- You don't know what you're doing
- You think you know what you're doing, but aren't sure of yourself
- You need pointers so you can do it yourself
- You want someone to fix your problems so you don't have to do any of the work yourself
Please be honest when answering that question.

It should be relatively easy to adapt that script. The key thing being getting SMTP working, of course.
We'll tackle that once you answer the questions I posed above.