Home Database Mysql Tutorial mysql 自动备份发邮件 到指定邮箱_MySQL

mysql 自动备份发邮件 到指定邮箱_MySQL

Jun 01, 2016 pm 01:48 PM
mail

bitsCN.com

 

首先 编写 导出的 命令 

使用了

mysqladmin ping

mysqldump

 

然后是 添加附件到邮件中发送

使用了对应的com

 

最后 暂停 看情况

 

参考:

http://hi.baidu.com/zd8695/blog/item/ae50b21c4b398a8087d6b6ac.html

见程序:

@echo on
:: mysql 目录 以及对应的盘符 和当前bat文件所在的盘符 和路径
set MYSQL_HOME=H:/wamp/bin/mysql/mysql5.5.16/bin
set MYSQL_DIR=H:
set EXECUTE_DIR=C:
set EXECUTE_HOME=C:/Users/fartpig/Desktop

:: 邮箱 账号 密码
set EMAIL_ACCOUNT=******@126.com
set EMAIL_PASS=******


echo start

 

 

echo save path

echo %cd%
set CURRENT_DIR=%cd%

echo export sql
%MYSQL_DIR%
cd %MYSQL_HOME%

echo try mysql
mysqladmin ping

mysqldump -u root -proot plane >plane.sql


echo send mail
%EXECUTE_DIR%
cd %CURRENT_DIR%
start %EXECUTE_HOME%/mail.vbs %EMAIL_ACCOUNT% %EMAIL_PASS% %MYSQL_HOME%/plane.sql

echo send success
pause

 

相应的 对应的 mail.vbs 

 

function Send_mail(You_Account,You_Password,Send_Email,Send_Email2,Send_Topic,Send_Body,Send_Attachment)
'code by NetPatch Changed by ZD8695
'VBS发送邮件参数说明
'You_Account:你的邮件帐号
'You_Password:你的邮件密码
'Send_Email:
'主要邮件地址
'Send_Email2: 备用邮件地址
'Send_Topic:
'邮件主题
'Send_Body:
'邮件内容
'Send_Attachment:邮件附件
You_ID=Split(You_Account, "@", -1, vbTextCompare)
'帐号和服务器分离
MS_Space = "http://schemas.microsoft.com/cdo/configuration/"
'这个是必须要的,不过可以放心的事,不会通过微软发送邮件
Set Email = CreateObject("CDO.Message")
Email.From = You_Account
'这个一定要和发送邮件的帐号一样
Email.To = Send_Email
'主要邮件地址
If Send_Email2 "" Then
Email.CC = Send_Email2
'备用邮件地址
End If
Email.Subject = Send_Topic
'邮件主题
Email.Textbody = Send_Body
'邮件内容
If Send_Attachment "" Then
Email.AddAttachment Send_Attachment
'邮件附件
End If
With Email.Configuration.Fields
.Item(MS_Space&"sendusing") = 2
'发信端口
.Item(MS_Space&"smtpserver") = "smtp."&You_ID(1)
'SMTP服务器地址
.Item(MS_Space&"smtpserverport") = 25
'SMTP服务器端口
.Item(MS_Space&"smtpauthenticate") = 1
'cdobasec
.Item(MS_Space&"sendusername") = You_ID(0)
'你的邮件帐号
.Item(MS_Space&"sendpassword") = You_Password
'你的邮件密码
.Update
End With
Email.Send
'发送邮件
Set Email=Nothing
'关闭组件
Send_Mail=True
'如果没有任何错误信息,则表示发送成功,否则发送失败
If Err Then
Err.Clear
Send_Mail=False
End If
End Function


If Send_Mail(wscript.arguments(0), wscript.arguments(1),wscript.arguments(0),"","数据库plane备份","看附件",wscript.arguments(2))=True Then
Wscript.Echo "发送成功"
Else
Wscript.Echo "发送失败"
End If

 

 

 

注: 使用可以修改相应的 注释中的内容 其中包括了四个参数 和两个 邮箱相关的

bat的目录和盘符

mail.vbs的目录和盘符

 

以及最后你的发邮箱的 地址和密码 , 也可以修改代码 发送到其他邮箱 注意 126的已经好用,不排除一些其他邮箱。。

 

bitsCN.com
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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 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)

Hot Topics

Java Tutorial
1664
14
PHP Tutorial
1269
29
C# Tutorial
1248
24
Outlook emails lost from control panel in Windows 11 Outlook emails lost from control panel in Windows 11 Feb 29, 2024 pm 03:16 PM

Is the Outlook mail icon missing from Windows 11's Control Panel? This unexpected situation has caused confusion and concern among some individuals who rely on OutlookMail for their communication needs. Why don't my Outlook emails show up in Control Panel? There may be several possible reasons why there are no Outlook mail icons in Control Panel: Outlook is not installed correctly. Installing Office applications from the Microsoft Store does not add the Mail applet to Control Panel. The location of the mlcfg32.cpl file in Control Panel is missing. The path to the mlcfg32.cpl file in the registry is incorrect. The operating system is not currently configured to run this application

Word mail merge prints blank page Word mail merge prints blank page Feb 19, 2024 pm 04:51 PM

If you find that blank pages appear when printing a mail merge document using Word, this article will help you. Mail merge is a convenient feature that allows you to easily create personalized documents and send them to multiple recipients. In Microsoft Word, the mail merge feature is highly regarded because it helps users save time manually copying the same content for each recipient. In order to print the mail merge document, you can go to the Mailings tab. But some Word users have reported that when trying to print a mail merge document, the printer prints a blank page or doesn't print at all. This may be due to incorrect formatting or printer settings. Try checking the document and printer settings and make sure to preview the document before printing to ensure the content is correct. if

Say goodbye to the Remote Mail Slot protocol in Windows 11 Say goodbye to the Remote Mail Slot protocol in Windows 11 Apr 14, 2023 pm 10:28 PM

We've been talking lately about the many features Microsoft plans to add to its latest operating system, Windows 11. But don't think that Microsoft will add nothing and take nothing back. In fact, the software giant started removing quite a few old features. After announcing plans to decommission MSDT functionality ahead of the release of Windows 12, a Redmond developer has more bad news. We are actually talking about remote mail slot legacy tool. Trust us when we say you actually want to know this. Microsoft has started deprecating this feature in build 25314. We are sure you remember that just a few days ago, Microsoft released build 25314 in its new canary channel. The above version contains many new features

How to Fix Outlook Email Stuck in Outbox Issue How to Fix Outlook Email Stuck in Outbox Issue May 01, 2023 am 10:01 AM

Recently, many users have reported the issue of Outlook emails getting stuck in the outbox. Even after several attempts to send the email, the issue was not resolved. When you see this issue and check your outbox folder, the message will be stuck there. Possible reasons for emails getting stuck in Outlook outbox: The attachments in the email exceed the size limit, which slows down the sending process. Outlook account authentication issues with mail server Incorrect send/receive settings in Outlook or mail server offline Outlook. Outlook data files are being used by some other software. Antivirus software scans outgoing emails. If this problem has been bothering you and you are unable to send an email

PHP sends emails asynchronously: avoid long waits for emails to be sent. PHP sends emails asynchronously: avoid long waits for emails to be sent. Sep 19, 2023 am 09:10 AM

PHP sends emails asynchronously: avoid long waits for emails to be sent. Introduction: In web development, sending emails is one of the common functions. However, since sending emails requires communication with the server, it often causes users to wait for a long time while waiting for the email to be sent. In order to solve this problem, we can use PHP to send emails asynchronously to optimize the user experience. This article will introduce how to implement PHP to send emails asynchronously through specific code examples and avoid long waits. 1. Understanding sending emails asynchronously

PHP email tracking function: understand user behavior and feedback on emails. PHP email tracking function: understand user behavior and feedback on emails. Sep 19, 2023 am 08:51 AM

PHP email tracking function: understand user behavior and feedback on emails In modern society, email has become an indispensable part of people's daily life and work. For businesses, sending emails is one of the important ways to communicate with customers and promote products or services. However, after an email is sent, how do we know whether it was received, read, or how the user reacted to the content of the email? At this time, the email tracking function becomes particularly important. The email tracking function can help us understand user behavior and feedback on emails

Fix: Error code 0x80070490 in Mail and Calendar apps in Windows 11, 10 Fix: Error code 0x80070490 in Mail and Calendar apps in Windows 11, 10 Apr 13, 2023 pm 09:13 PM

Some Windows users have reported the error message "Something went wrong, we're sorry, but we can't do it" along with error code 0x80070490 on the screen while trying to add Gmail or any other email account to the Mail app on Windows PC . Even after multiple attempts, customers were unable to add any email account to their mail application. Users are very dissatisfied and unsure of how to move from here. The possible reasons for this error while adding email account in mail application could be corruption of system data files, some internal issues of mail application, outdated mail application, etc. After analyzing the above possible reasons for this error

How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad How to set Gmail to delete instead of archive in the Mail app on iPhone and iPad Apr 13, 2023 pm 02:34 PM

Have you noticed that when you try to delete a message in Gmail on iOS, you only see the archive option? Read on to learn how to delete Gmail on iPhone without archiving it in the Mail app. The setting to change the default option for archiving Gmail emails using the Mail app on iPhone and iPad is completely hidden in Settings, but it can be changed quickly once you know where to go. Keep in mind that this tutorial is for people using Gmail through the Apple Mail app on iPhone and iPad. Another option is to use the Gmail app on your iPhone/iPad. you even

See all articles