How to send email with an attachment in PHP using PHPMailer

Firstly, download the PHPMailer library from the given link :

Now extract the zip folder and rename it to ‘PHPMailer’ and place it in your root folder where all the php files are located.

Then after put this code :

$mail = new PHPMailer();
$mail->From = ''; /* put the email from which the email is to be sent */
$mail->FromName = ''; /* put the name of a person who is sending email */
$mail->Subject = ''; /* give a subject of email if you want */
$message_body = "Hello, sending mail using PHPMailer";
$mail->Body = $MESSAGE_BODY;
$mail->AddAddress( '' ); /* put the email of the recipient */

$mail->AddAttachment('PATHTOFILE'); /* put the path to the file */

if ($mail->Send())
echo "Mail Sent";
echo "Could not send mail";