You have to move lines 307-314 down below the email code. That is redirecting people to the success page before the email can be sent.
It looks like you might also want to add the Host, Port, and Authorization settings to the original email on lines 316-327 if you want that email to send with your smtp server. If you don't want both emails, then you could just delete that code as well.