python微信远程控制摄像头_python编写微信远程控制电脑的程序

# -*- coding:utf-8 -*-

from email.mime.text import MIMEText

import poplib

import smtplib

import os

class MailManager(object):

def __init__(self):

self.popHost = 'pop.sina.com'

self.smtpHost = 'smtp.sina.com'

self.port = 25

self.userName = 'ivanzgj@sina.com'

self.passWord = 'zgj123'

self.bossMail = '475176416@qq.com'

self.login()

self.configMailBox()

# 登录邮箱

def login(self):

try:

self.mailLink = poplib.POP3_SSL(self.popHost)

self.mailLink.set_debuglevel(0)

self.mailLink.user(self.userName)

self.mailLink.pass_(self.passWord)

self.mailLink.list()

print u'login success!'

except Exception as e:

print u'login fail! ' + str(e)

quit()

# 获取邮件

def retrMail(self):

try:

mail_list = self.mailLink.list()[1] if len(mail_list) == 0:

return None

mail_info = mail_list[0].split(' ')

number = mail_info[0] mail = self.mailLink.retr(number)[1] self.mailLink.dele(number)

subject = u''

sender = u''

for i in range(0, len(mail)):

if mail[i].startswith('Subject'):

subject = mail[i][9:] if mail[i].startswith('X-Sender'):

sender = mail[i][10:] content = {'subject': subject, 'sender': sender}

return content

except Exception as e:

print str(e)

return None

def configMailBox(self):

try:

self.mail_box = smtplib.SMTP(self.smtpHost, self.port)

self.mail_box.login(self.userName, self.passWord)

print u'config mailbox success!'

except Exception as e:

print u'config mailbox fail! ' + str(e)

quit()

# 发送邮件

def sendMsg(self, mail_body='Success!'):

try:

msg = MIMEText(mail_body, 'plain', 'utf-8')

msg['Subject'] = mail_body

msg['from'] = self.userName

self.mail_box.sendmail(self.userName, self.bossMail, msg.as_string())

print u'send mail success!'

except Exception as e:

print u'send mail fail! ' + str(e)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值