I'm trying to attach my backup zip file to my gmail. about 300kb zip file iam trying to use this code
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\Exception;
require 'Exception.php';
require 'PHPMailer.php';
require 'SMTP.php';
$mail = new PHPMailer(true);
try {
$mail->IsHTML(true);
$mail->SetFrom('info@myDomain.net', 'ADMIN');
$mail->Subject = 'mysite - Backup Files - ' . date('d-M-Y');
$mail->Body = 'This is your backup files date: ' . date('d-M-Y');
$mail->AddAddress( 'myMail@gmail.com' );
$mail->addAttachment('secret-backup-03-Apr-2019-2105361.zip');
$mail->send();
echo 'Message has been sent';
} catch (Exception $e) {
echo "Message could not be sent. Mailer Error: {$mail->ErrorInfo}";
}
?>
my zip archive is created with this php code:
<?php
function backup()
{
$name = "";
$name = "./backup/backup-".date('d-M-Y').'-'.date('His').".zip";
shell_exec("zip -q -e -9 -P 12345678 -r " . $name . " /home/user/public_html/* -x /home/user/public_html/CMD/backup/**\*");
$secretname = "";
$secretname = "./backup/secret-backup-".date('d-M-Y').'-'.date('His').".zip";
shell_exec("zip -q -e -9 -P 12345678 -r " . $secretname . " " . $name);
if (file_exists($secretname)) {
unlink($name);
}
}
backup();
?>
but the mail don't arrive to my gmail
i changed the file from secret-backup-03-Apr-2019-2105361.zip
to testfile.rtf
with the exact same code the mail arrived with the attachment!!
any help ??!
EDIT: according to A4L answer i tried to send to mymail@outlook.com with the same code and the mail arrived successfully.
Now its Gmail problem. Any help??