PHPMailer is very popular library to send emails through SMTP. Due to it's integrated SMTP configurator and email's header formatter, it is extremely useful and powerful.
You can find the full video tutorial on How to use PHPMailer to send emails through PHP down below. and make use of source code too.
Troubleshooting
- There is a bug in your PHP Installation. Try to upgrade and change ------------ in your php.ini
Sol. Download Latest Local Server Utility, Uninstall Previous and Install Downloaded. - Cannot Instantiate Mailer
Sol. Make sure your php.ini mail setting is at default state (not tweaked) or check your SMTP credentials or Allow less secure apps in case of Google SMTP or Try to run on a production server. - Sending Mails to unwanted recipients
Sol. Make sure you have cleared the recipients through ClearAllRecipients();
For other troubles, do comment below.