Mysql automatically backs up and sends emails to the specified mailbox _ MySQL

Source: Internet
Author: User
Tags email account
Mysql automatically backs up and sends emails to the specified email address bitsCN.com.
Mysql automatically backs up and sends emails to a specified mailbox. First, write the export command using mysqladmin pingmysqldump, and then add the attachments to the email. use the corresponding com to suspend the emails. for details, refer: http://hi.baidu.com/zd8695/blog/item/ae50b21c4b398a8087d6b6ac.html See the program: @ echo on: mysql directory, the corresponding drive letter, and the drive letter and path of the current bat file set MYSQL_HOME = H: /wamp/bin/mysql/mysql5.5.16/binset MYSQL_DIR = H: set EXECUTE_DIR = C: set EXECUTE_HOME = C:/Users/fartpig/Desktop :: email account password set EMAIL_ACCOUNT = ****** @ 126. comset EMAIL_PASS = ****** echo start echo save pathecho % cd % set CURRENT_DIR = % cd % echo export SQL % MYSQL_DIR % cd % MYSQL_HOME % echo try mysqlmysqlmysqladmin pingmysqldump-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. sqlecho send successpause corresponding 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 parameter description for sending an email 'You _ Account: your Email account 'You _ Password: your Email Password 'send _ Email: 'Main Email address' Send _ Email2: alternate Email address' Send _ Topic: 'mail topic 'send _ Body: 'mail content' Send _ Attachment: email Attachment You_ID = Split (You_Account, "@",-1, vbTextCompare) 'Account and server separation MS_Space =" http://schemas.microsoft.com/cdo/configuration/ "'This is a must, but you can rest assured that the Mail Set Email = CreateObject (" CDO. message ") Email. from = You_Account 'must be the same as the account that sent the Email. to = Send_Email 'main Email address If Send_Email2 <> "" Then Email. CC = Send_Email2 'backup Email address End If Email. subject = Send_Topic 'Email Subject. textbody = Send_Body 'mail content If Send_Attachment <> "" Then Email. addAttachment Send_Attachment 'email attachment End If With Email. configuration. fields. item (MS_Space & "s Endusing ") = 2' sending port. item (MS_Space & "smtpserver") = "smtp. "& You_ID (1) 'smtp server address. item (MS_Space & "smtpserverport") = 25 'smtp server port. item (MS_Space & "smtpauthenticate") = 1 'cdobasec. item (MS_Space & "sendusername") = You_ID (0) 'your email account. item (MS_Space & "sendpassword") = You_Password 'your email password. update End With Email. send 'send Mail Set Email = Nothing 'close component Send_Mail = true' If no error message exists, it indicates that the message is sent successfully. Otherwise, If Err Then Err fails to be sent. Clear Send_Mail = False End If End Function If Send_Mail (wscript. arguments (0), wscript. arguments (1), wscript. arguments (0), "", "database plane backup", "View attachment", wscript. arguments (2) = True Then Wscript. echo "sent successfully" Else Wscript. echo "failed to send" End If note: you can modify the content in the corresponding comment, which includes four parameters and two mailbox-related bat directories and drive letters mail. the vbs directory and drive letter, as well as the address and password of your mailbox at last, can also be modified to send code to other mailboxes. Note that 126 is useful and some other mailboxes are not excluded .. BitsCN.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.