python 邮件发送

python 2.7代码如下:

#coding: utf-8
import smtplib
from email.mime.text import MIMEText

#connect smtp server
msg = MIMEText(‘Hello’,’plain’,’utf-8′)
msg[‘Subject’] = ‘ Load data sucess!’
#msg[‘Date’] = formatdate(localtime=True)
smtp = smtplib.SMTP()
smtp.connect(‘proxy-in.xxx.com’)
smtp.sendmail(‘bidev@xxx.com’, ‘swer@xxx.com’, msg.as_string())

 

python 2.4.3

#coding: utf-8
import smtplib
from email.MIMEText import MIMEText

#connect smtp server
msg = MIMEText(‘Hello’,’plain’,’utf-8′)
msg[‘Subject’] = ‘ Load data sucess!’
smtp = smtplib.SMTP()
smtp.connect(‘proxy-in.xxx.com’)
smtp.sendmail(‘bidev@xxx.com’, ‘hsdf@xxx.com’, msg.as_string())

unable to correct problems you have held broken packages

OS:  Ubuntu 14.04

When installing a ubuntu desktop KDE,  some error  like “unable to correct problems you have held broken packages” happen.  So I finally found the problm is the package python3-software-properties is too new and can’t be compatible with the kde package. The soluation is follling:

sudo apt-get remove python3-software-properties

sudo apt-get install python3-software-properties=0.92.36

查看端口是否占用

环境 :CentOS

[root@sandbox ~]# lsof -i:80
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
httpd 1118 root 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1255 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1256 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1257 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1258 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1259 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1260 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1261 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)
httpd 1262 apache 4u IPv6 9178 0t0 TCP *:http (LISTEN)

Ubuntu升级慎重

环境:ubuntu 12.04, ubuntu 14.04, wordpress 4.0, opencart 1.5, postgresql 9.1, mysql 5

昨天升级ubuntu系统至14.04版本后,发现之前安装的wordpress和opencart全线瘫痪。(冒汗不止)。这两个主页都是空白的,无任务报错信息。只能到网上狂搜一把。解决方案如下

wordpress:

“无法选择数据库”(postgresql),试过各种方法,最后只能把wordpress降版本至3.4.2

wget https://cn.wordpress.org/wordpress-3.4.2-zh_CN.tar.gz

重新布置到/var/www目录下。 (注意ubuntu 14.04的apache2的DocumentRoot与之前不同位置。

sudo vi /etc/apache2/sites-enabled/000-default.conf

将DocumentRoot /var/www/html修改为DocumentRoot /var/www)

还是一个问题是wordpress默认主题需要更改,否则也是只能看到空白页面

 

opencart:

增加一行到index.php显示出错日志

<?php
ini_set(‘display_errors’, ‘on’);
?>

Fatal error: Call to undefined function mcrypt_create_iv() is that mcrypt

重新安装mcrypt和php5-mcrypt

sudo apt-get install mcrypt
sudo apt-get install php5-mcrypt

php -m | grep mcrypt

加载模块

sudo php5enmod mcrypt

 

今天是几乎花费半天的时间来处理这两个应用的问题, 网上的解决方法也是只能给个思路。只能自己深入地了解问题才能定位并解决。还有一点,升级系统切记要慎重!