- towjzhou
- 等级:


- 性别:
 - 文章: 132
- 积分: 458
- 来自: 杭州

|
GSend.py
python 代码
- """GMail file sender: Send a file use GMail.
- """
-
- from __future__ import with_statement
- import os
- import sys
- from smtplib import SMTP
- from email.MIMEMultipart import MIMEMultipart
- from email.mime.application import MIMEApplication
- import time
-
- if len(sys.argv) < 2:
- print 'Usage: python %s <file path>' % os.path.basename(sys.argv[0])
- sys.exit(-1)
-
- config = {
- 'from': "XXX XXX@gmail.com
- 'to': 'XXX@hotmail.com',
- 'subject': '[gsend]Send file %s' % sys.argv[1],
- 'file': sys.argv[1],
- 'server': 'smtp.gmail.com',
- 'port': 587,
- 'username': 'XXX@gmail.com',
- 'password': 'xxxxxx',
- }
-
- print 'Preparing...',
-
- message = MIMEMultipart( )
- message['from'] = config['from']
- message['to'] = config['to']
- message['Reply-To'] = config['from']
- message['Subject'] = config['subject']
- message['Date'] = time.ctime(time.time())
-
- message['X-Priority'] = '3'
- message['X-MSMail-Priority'] = 'Normal'
- message['X-Mailer'] = 'Microsoft Outlook Express 6.00.2900.2180'
- message['X-MimeOLE'] = 'Produced By Microsoft MimeOLE V6.00.2900.2180'
-
- with open(config['file'], 'rb') as f:
- file = MIMEApplication(f.read())
- file.add_header('Content-Disposition', 'attachment', filename=os.path.basename(config['file']))
- message.attach(file)
-
- print 'OK'
- print 'Logging...',
-
- smtp = SMTP(config['server'], config['port'])
- smtp.ehlo()
- smtp.starttls()
- smtp.ehlo()
- smtp.login(config['username'], config['password'])
-
- print 'OK'
- print 'Sending...',
-
- smtp.sendmail(config['from'], [config['from'], config['to']], message.as_string())
-
- print 'OK'
-
- smtp.close()
-
- time.sleep(1)
GSend.bat
python 代码
- @REM put this file in to windows "Send to" folder
-
- python c:/gsend.py "%1"
- @pause
然后就是右键->WinRAR->压缩成一个文件->右键->Send to->gsend.bat
声明:ITeye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
|
返回顶楼 |
|
|
- javan
- 等级: 初级会员

- 文章: 10
- 积分: 45

|
不错,抽空试用一下
不知道其它的邮件服务器也适用不?
|
返回顶楼 |
|
|
- noble
- 等级: 初级会员

- 性别:
 - 文章: 39
- 积分: 60
- 来自: Peking

|
使用标准的邮件发送协议的,其它的应该都支持。
应该再考虑一下附件大小的处理。
|
返回顶楼 |
|
|
- stone
- 等级:


- 性别:
 - 文章: 187
- 积分: 411
- 来自: 天津

|
呵呵,如果使用gmail备份的话,为什么不考虑使用gspace呢?
|
返回顶楼 |
|
|
- eonhy
- 等级:


- 性别:
 - 文章: 50
- 积分: 102
- 来自: 四川成都

|
这个想法不错。。。
我看在公司内部局域网上可以实现以Lotus Domino邮件服务为基础的网络硬盘
|
返回顶楼 |
|
|