07 Jan, 2018

How to send mail in PHP with attachment using PHP Mailer

07 Jan, 2018

Dear Reader, let us know that, “How to send mail in PHP with attachment using PHP Mailer“. So in this Tutorial, We Learn Step By Step Mail Sending Process using phpmailer in PHP.

Mail Sending functionality is very important for any Organisation to notify any user to send information Immediately.

In PHP mail() function allows us to send email directly from a script. The mail() function accepts the no. of parameters like

PHPMailer is one of the most popular open source PHP libraries to send emails. t has become a PHP developer’s favorite way of sending emails programmatically

i) Email

ii) Subject

iii) Message

iv) CC Email or BC Email

In the above Parameters Email, Subject and Message Parameters are Mandatory and Rest of Parameters are Optional.

Lets first we see a demo by click on bellow “Demo” Button

Step 1:- Now we need to create index.php file in our project like “htdocs/webpreprations/demo/how-to-send-mail-using-php-mailer-in-php/index.php” and paste bellow code

Step 2:- Now we need to download phpmailer here

Step 3:- Now we extract zip folder in our project’s root directry like “htdocs\webpreprations\demo\mail\PHPMailer” as we can see in bellow snapshot

how-to-send-mail-in-PHP-with-attachment-using-PHPMailer-step-2

Step 4:- Now we create “upload” folder for containing attachments and copy attachment file like “.pdf”, “.docx” etc file which we want to attach to mail

Step 5:- Now run our project, so we need to type in browser localhost/your_project_name/mail/file_name.php

like

http://localhost/webpreprations/demo/how-to-send-mail-using-php-mailer-in-php/index.php then you can see the result as in below snapshot, you can Send mail By click on Send Mail button

how-to-send-mail-in-PHP-with-attachment-using-PHPMailer-step-1

Congratulations you have successfully Completed Mail Sending Process using phpmailer with attachments in PHP, if you like this post and was helpful for you then share this post on social media and if you have any query then please contact us or comment below and don’t Forget Like and Follow us on Social MediaThanks.

 

Related Articles
«
»

Leave a comment:

Your email address will not be published. Required fields are marked *