Click here to Skip to main content
15,745,574 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi Team

I need some clarity on using php without composer, for example i need to have all phpmailer files to send email with attachment to my project. I downloaed them online and want to use them on my project to send email with attachment.
The problem now if i am using c-panel as an external server, will downloaded files still worked to accomplished this?

the lib/vendor/phpmailer/phpmailer is the current directory on c-panel and its the directory currently using to use for phpmailer. Please advice if i am missing something important.

What I have tried:


        $mailto = $_POST['mail_to'];
        $mailSub = $_POST['mail_sub'];
        $mailMsg = $_POST['mail_msg'];
       require 'lib/vendor/phpmailer/phpmailer';
       $mail = new PHPMailer();
       $mail ->IsSmtp();
       $mail ->SMTPDebug = 0;
       $mail ->SMTPAuth = true;
       $mail ->SMTPSecure = 'ssl';
       $mail ->Host = "";
       $mail ->Port = 465; // or 587
       $mail ->IsHTML(true);
       $mail ->Username = "";
       $mail ->Password = "accountsamplepassword";
       $mail ->SetFrom("");
       $mail ->Subject = $mailSub;
       $mail ->Body = $mailMsg;
       $mail ->AddAddress($mailto);
       $mail->AddAttachment('pdf_files/reservation.pdf', 'reservation.pdf');

           echo "Mail Not Sent";
           echo "Mail Sent";

Member 15627495 3-Mar-23 8:25am    
require 'lib/vendor/phpmailer/phpmailer';
// it's a path to phpmailer package.

once you have the same 'path' to your file 'phpmailer' , all emails will be sent.
Gcobani Mkontwana 3-Mar-23 9:18am    
@Member 15627495 fully agree but i am still researching to get enough information on this topic so can fully understand it
Andre Oosthuizen 6-Mar-23 7:07am    
Do not ever hardcode your paths to any of your files, it is bound to error some or other time in it's life -

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900