/    Sign up×
Community /Pin to ProfileBookmark

Script to Email when Job is Complete (CC Code)

Hey Guys,

I really seems to be struggling here,

The Script is to Run through a Directory on the server, Zip it up and Connected to the SQL Database, make a Dump of it and add that to the Compressed File.

At the end of the Script it Emails me the Site its backed up and a Link to the File
(Then Also a Link to delete the backup once its downloaded)

The Problem is i cannot seem to get a CC Code working on the Email part,

Here is the Code in Different Parts of Files:

All am trying to do is to send it to 2 email Address,

Config File:

[code=php]$sitename = “COMPANY NAME”;
$siteaddress = “www.DOMAIN NAME.co.uk”;
$backupName = “BACKUPNAME-“.date(‘d-m-y’).’.zip’;
$downloadlink = “$siteaddress/Backup/backup/$backupName”;
$deletefile =”$siteaddress/Backup/delete.php”;
$configEmail = ‘EMAIL ADDRESS’;
[/code]

Functions File:

[code=php]function mailAttachment($file, $mailto, $from_mail, $from_name, $replyto, $subject, $message) {

// $filename = basename($file);
// $file_size = filesize($file);
$handle = fopen($file, “r”);
// $content = fread($handle, $file_size);
fclose($handle);
// $content = chunk_split(base64_encode($content));
$uid = md5(uniqid(time()));
// $name = basename($file);
$header = “From: “.$from_name.” <“.$from_mail.”>rn”;
$header .= “Reply-To: “.$replyto.”rn”;
$header .= “MIME-Version: 1.0rn”;
$header .= “Content-Type: multipart/mixed; boundary=””.$uid.””rnrn”;
$headers .= “Content-Transfer-Encoding: 7bit”.”rn”;
$header .= “This is a multi-part message in MIME format.rn”;
$header .= “–“.$uid.”rn”;
$header .= “Content-type:text/html; charset=iso-8859-1rn”;
$header .= “Content-Transfer-Encoding: 8bitrnrn”;
$header .= $message.”rnrn”;
$header .= “–“.$uid.”rn”;
$header .= “Content-Type: application/octet-stream; name=””.$filename.””rn”; // use diff. tyoes here
$header .= “Content-Transfer-Encoding: base64rn”;
$header .= “Content-Disposition: attachment; filename=””.$filename.””rnrn”;
// $header .= $content.”rnrn”;
$header .= “–“.$uid.”–“;
if (mail($mailto, $subject, “”, $header)) {
echo “Backup has been Complete Email Sent”; // or use booleans here
} else {
echo “There has been a Error Please Contact Dave”;
}
} [/code]

Backup File:

[code=php]if (isset($configEmail) && !empty($configEmail))
{
mailAttachment($fileName,$configEmail,’[email protected]’,’Website Backup Complete’,’[email protected]’,”.$siteaddress,”The Backup has been Completed Sucsesfully for: <br><br> $sitename, <br> <br> Please Download The Back and Remove From the Server <br> <br> Domain $siteaddress <br> <br> <br> Download Link: $downloadlink <br> <br> <br> Once Downloaded Click the following link to delete the file <br> $deletefile <br> <br> <br> <br> <br> <br> Regards <br> <br> Dave”);
}[/code]

Thanks

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @Dave7802 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...