You probably want to send an email from your code, well you can use a PHP in built function mail(), but since you are here, chances are that it is either you have tried it and stuck or may be you just need a simpler way to reach your goal since the PHP mail() has a handful of limitations when it comes to making use of popular features such as:
- encryption
- authentication
- HTML messages and
- attachments.
Well, thanks to PHPMailer the classic email sending library for PHP, it is open source and can be can be installed through by adding this line to your
composer.json file:"phpmailer/phpmailer": "^6.2" or run
composer require phpmailer/phpmailer Alternatively, if you're not using Composer, you can download PHPMailer as a zip file , then copy the contents into one of the include_path directories specified in your PHP configuration and load each class file manually.I have downloaded the library manually but you can use any of the above steps and reach the same destination.First, let us load the classes that we will use into a global namespace,
ensure this is on top of your script and not inside a function.Now load the composer's autoloader
includes and PHPMailer are my folders where vendor/autoload.php exists, you can change them with where the file is vendor /autoload.phpexistsAfter this, now we have one thing left before making your hands dirty. ![]() |
Ready now to get your hands dirty, do not forget to move to part 2Follow and share for more tech issues.Take your time and leave a comment. Thank you



Comments
Post a Comment