gcozba2023
New member
Hi Team
I have a phpmailer file that send email with attached document, but i now get this weird error. How do i get rid of this error from this path when using phpmailer?
PHP Warning: require(..\_lib\vendor\phpmailer\phpmailer): failed to open stream: No such file or directory in /home/acifinan/public_html/send-email-attachment.php on line 3
// code to send attachment for pdf
I have a phpmailer file that send email with attached document, but i now get this weird error. How do i get rid of this error from this path when using phpmailer?
PHP Warning: require(..\_lib\vendor\phpmailer\phpmailer): failed to open stream: No such file or directory in /home/acifinan/public_html/send-email-attachment.php on line 3
// code to send attachment for pdf
Code:
require '..\_lib\vendor\phpmailer\phpmailer';
use PHPMailer\PHPMailer;
$msg = '';
if (array_key_exists('bankstatement', $_FILES)) {
//Create a message
$mail = new PHPMailer();
$mail->setFrom('info@acifinance', 'ACI Finance');
$mail->addAddress('gcobani.mkontwana@agilelimitless.org.za', '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!';
}
}
?>
// html code to attached documents as pdf
<fieldset>
SELECT A pdf FILE TO UPLOAD
<br>
<label>ID </label><br>
<input type="File" name="id" id="id" accept=".pdf">
<br>
<label>Bank Statement </label><br>
<input type="File" name="bankstatement" id="bankstatement" accept=".pdf">
<br>
<label>Pay Slip </label><br>
<input type="File" name="payslip" id="payslip" accept=".pdf">
<br>
<input type="Submit" id="btnNow" class="btn apply-btn mt-30" name="button" value="APPLY NOW">
</fieldset>