Home Backend Development PHP Tutorial Use PHP to back up MySQL and send the website to the mailbox example code_PHP tutorial

Use PHP to back up MySQL and send the website to the mailbox example code_PHP tutorial

Jul 13, 2016 pm 05:17 PM
bin mysql php usr code use and backup copy Example website Mail

复制代码 代码如下:

#!/usr/local/bin/php.cli
require_once './lib/swift_required.php';

//MySQL
$mysql_dbname = "db";
$mysql_user = "user";
$mysql_pass = "pass";
$mysql_file = "./xxx.sql";
$mysql_charset = "utf8";
system("mysqldump --default-character-set=$mysql_charset --opt -u$mysql_user -p$mysql_pass $mysql_dbname > $mysql_file");

//Backup WWW File
$www_path = "../www/";
@$final_file = "./xxx_com_".date("Y_m_d").".zip";
system("zip -r -q $final_file $www_path $mysql_file");

//E-Mail
@$mail_title = "Backup for Coder4.com ".date("Y_m_d");
$mail_sender = "xxx_send@vip.qq.com";
$mail_recver = "xxx_recv@vip.qq.com";
$mail_body = "See attachments";
$mail_file = $final_file;
$sendmail_cmd = "/usr/sbin/sendmail -bs";

//Create E-Mail
$message = Swift_Message::newInstance();
$message->setSubject($mail_title);
$message->setFrom(array($mail_sender));
$message->setTo(array($mail_recver));
$message->setBody($mail_body);
$message->attach(Swift_Attachment::fromPath($mail_file));
//echo $message->toString();

//Send E-Mail
$transport = Swift_SendmailTransport::newInstance($sendmail_cmd);
$mailer = Swift_Mailer::newInstance($transport);
$result = $mailer->send($message);

//Delete
unlink($final_file);
unlink($mysql_file);

//End
echo "All backup success."
?>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/621709.htmlTechArticle复制代码 代码如下: #!/usr/local/bin/php.cli ?php require_once './lib/swift_required.php'; //MySQL $mysql_dbname = "db"; $mysql_user = "user"; $mysql_pass = "pass"; $mysql_f...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

binance download APP binance Binance platform download free APP binance download APP binance Binance platform download free APP Mar 18, 2025 pm 01:54 PM

This article introduces in detail two methods for downloading Binance APP on Apple iOS system and Android system mobile phones. For iOS systems, since the App Store in China cannot be downloaded directly, users need to use the Apple ID in the outer zone, and they can choose to borrow or register the Apple ID in the outer zone to download it. Android users can directly search and install it in the app store, or visit Binance's official website to scan the QR code to download the installation package. It should be noted that when downloading applications from unofficial channels, you may need to enable the application installation permissions of unknown sources on your phone. No matter which system you are, you can use the Binance APP after downloading.

The latest registration portal for Ouyi official website The latest registration portal for Ouyi official website Mar 21, 2025 pm 05:54 PM

As the world's leading digital asset trading platform, Ouyi OKX attracts many investors with its rich trading products, strong security guarantees and convenient user experience. However, the risks of network security are becoming increasingly severe, and how to safely register the official Ouyi OKX account is crucial. This article will provide the latest registration portal for Ouyi OKX official website, and explain in detail the steps and precautions for safe registration, including how to identify the official website, set a strong password, enable two-factor verification, etc., to help you start your digital asset investment journey safely and conveniently. Please note that there are risks in digital asset investment, please make cautious decisions.

Ouyi Exchange web version registration portal Ouyi registration portal Ouyi Exchange web version registration portal Ouyi registration portal Mar 20, 2025 pm 05:48 PM

This article details how to register an account on the official website of Ouyi OKX Exchange and start cryptocurrency trading. As the world's leading cryptocurrency exchange, Ouyi provides a wide range of trading varieties, multiple trading methods and strong security guarantees, and supports convenient withdrawal of a variety of fiat and cryptocurrencies. The article covers the search methods for Ouyi official website registration entrance, detailed registration steps (including email/mobile registration, information filling, verification code verification, etc.), as well as precautions after registration (KYC certification, security settings, etc.), and answers common questions to help novice users quickly and safely complete Ouyi account registration and start a cryptocurrency investment journey.

Ouyi official website registration portal 2025 Ouyi official website registration portal 2025 Mar 21, 2025 pm 06:00 PM

2025 Ouyi OKX Registration Entrance Guide: Plan ahead and trade safely! Digital currency transactions are changing rapidly, and it is crucial to understand the 2025 Ouyi registration entrance and process in advance. This article predicts that in the future registration may face stricter KYC/AML requirements, biometric technology applications, mobile-first strategies and global compliance adjustments. We will explain the key steps of secure registration in detail, including selecting official channels, setting strong passwords, enabling two-factor verification, protecting personal information, etc., to help you avoid risks, register an Ouyi OKX account safely and conveniently, and start a digital asset trading journey.

Is MOTHER currency online on the exchange? How to buy MOTHER coins? Is MOTHER currency online on the exchange? How to buy MOTHER coins? Mar 05, 2025 pm 06:30 PM

MOTHER Coin, a highly anticipated meme coin launched by IggyAzalea, has quickly set off a craze in the cryptocurrency circle with its unique brand strategy and a growing user base. The MOTHER project marks an important step in the integration of blockchain technology and the art and entertainment industry, aiming to be the core of the MotherIggy ecosystem. However, for investors interested in investing, it is crucial to know whether MOTHER is available on the exchange. The answer is yes. This article will take stock of the exchanges on which MOTHER coins have been launched. The launch of MOTHER currency exchanges is currently on multiple exchanges, including Gate.io, Bitget, MEXC, XT.CO

Detailed tutorial on how to register for binance (2025 beginner's guide) Detailed tutorial on how to register for binance (2025 beginner's guide) Mar 18, 2025 pm 01:57 PM

This article provides a complete guide to Binance registration and security settings, covering pre-registration preparations (including equipment, email, mobile phone number and identity document preparation), and introduces two registration methods on the official website and APP, as well as different levels of identity verification (KYC) processes. In addition, the article also focuses on key security steps such as setting up a fund password, enabling two-factor verification (2FA, including Google Authenticator and SMS Verification), and setting up anti-phishing codes, helping users to register and use the Binance Binance platform for cryptocurrency transactions safely and conveniently. Please be sure to understand relevant laws and regulations and market risks before trading and invest with caution.

Deepseek official website portal address is Deepseek official website portal address is Mar 12, 2025 pm 02:42 PM

The Deepseek official website portal address is https://www.deepseek.com/​ , enter it in the browser address bar to access it.

Gate Exchange official website login Gate Exchange official website login Mar 05, 2025 pm 07:45 PM

To log in to your account on the official website of Gate.io, please follow the following steps: Visit the official website of Gate.io and click the "Login" button. Enter your registered email or mobile phone number and password, and fill in the sliding verification code. If necessary, enter the SMS verification code or the dynamic verification code provided by Google Verifier. Finally, click "Login" to log in successfully.

See all articles