PHP Fatal error: Uncaught Error: Call to undefined method PHPMailer::setFrom()


New member
Hi Team

I need help with my file directories in order for me to send multiple attachments as pdf to a client, challenge now each time when i use phpmailer class its not finding it. While on my server is as this directories..


// current code to call these from the server using script

require_once 'PHPMailer/PHPMailerAutoload.php';
use PHPMailer;

$msg = '';
if (array_key_exists('bankstatement', $_FILES)) {
    //Create a message
    $mail = new PHPMailer();
    $mail->setFrom('info@acifinance', 'ACI Finance');
    $mail->addAddress('', 'ACI Finance');
    $mail->Subject = 'ACI Finance Application Loan';
    $mail->Body = 'My message body';
    //Attach multiple files one by one
    for ($ct = 0, $ctMax = count($_FILES['bankstatement']['tmp_name']); $ct < $ctMax; $ct++) {
        //Extract an extension from the provided filename
        $ext = PHPMailer::mb_pathinfo($_FILES['bankstatement']['name'][$ct], PATHINFO_EXTENSION);
        //Define a safe location to move the uploaded file to, preserving the extension
        $uploadfile = tempnam(sys_get_temp_dir(), hash('sha256', $_FILES['bankstatement']['name'][$ct])) . '.' . $ext;
        $filename = $_FILES['bankstatement']['name'][$ct];
        if (move_uploaded_file($_FILES['bankstatement']['tmp_name'][$ct], $uploadfile)) {
            if (!$mail->addAttachment($uploadfile, $filename)) {
                $msg .= 'Failed to attach file ' . $filename;
        } else {
            $msg .= 'Failed to move file to ' . $uploadfile;
    if (!$mail->send()) {
        $msg .= 'Mailer Error: ' . $mail->ErrorInfo;
    } else {
        $msg .= 'Message sent!';
What version of phpmailer do you use?
Yo need also set the sender (the smtp for example).
Please show the whole logs for the current request