webpy中配置发送邮件服务

树莓派实战2:发送ip地址到自己邮箱 接上: 2、 发送邮件的程序: 网上有很多做法,通过web.py自带的库来发送邮件最为方便 先配置python +web.py shell中输入 python  如果显示 Python 2.7.3,说明打开python2成功(如果要退出,ctrl+z) 继续输入import web  如果ImportError: No module named xxx,则未安装web.py 阅读详情

官方cookbook链接:http://webpy.org/cookbook/sendmail.zh-cn

前提:需要安装web.py了,因为我这个web应用是用web.py写的

#!\urs\bin\env python
#encoding: utf-8
import web

def send_mail(send_to, subject, body, cc=None, bcc=None):
    '''
    @把找回密码的内容作为邮件发送出去
    '''
    try:
        web.config.smtp_server = 'smtp.163.com'   ##邮件发送服务器
        web.config.smtp_port = 25    ##不设置将使用默认端口
        web.config.smtp_username = 'username'   ##邮件服务器的登录名
        web.config.smtp_password = 'password'   ##邮件服务器的登录密码
        web.config.smtp_starttls = True
        send_from = 'username@163.com'    ##发送的邮件
        web.sendmail(send_from, send_to, subject, body, cc=cc, bcc=bcc)
        return 1  #pass
    except Exception, e:
        print e
        return -1 #fail

if __name__=='__main__':
    send_to = ['someone1@qq.com', 'someone2@sina.com']   
    subject = '邮件标题'
    body = '邮件内容\n可以有回车'
    cc = ['someone1@qq.com', 'someone2@sina.com']   ##抄送
    bcc = ['someone1@qq.com', 'someone2@sina.com']  ##密抄
    send_mail(send_to, subject, body, cc, bcc)


CentOS 6.5部署iRedMail实战指南:老旧系统邮件服务搭建 邮件服务器是企业基础通信设施的核心组件,其部署需兼顾协议规范(SMTP/IMAP/POP3)、安全机制(TLS加密、SPF/DKIM、LDAP认证)与系统兼容性。在遗留系统运维场景中,CentOS 6.5因glibc 2.12和SysVinit架构,仍广泛承载ERP、HIS等关键业务,形成典型的‘技术债务锁定’。此时选择适配该环境的iRedMail 0.9.7版本,可快速构建具备反垃圾(SpamAssassin+ClamAV)、集中管理(OpenLDAP后端)和等保合规能力的自建邮件系统。本文聚焦真实生产约 阅读详情

相关推荐

iRedMail在CentOS 6.5 x64上的安全部署与等保合规实践

邮件服务器是企业基础通信设施的核心组件,其部署需兼顾协议栈原理、系统安全机制与合规要求。Linux邮件服务通常基于Postfix、Dovecot、MySQL等开源组件协同工作,依赖SSL/TLS加密、SELinux强制访问控制、iptables网络策略及SMTP/IMAPS协议规范。在政企老旧环境中,CentOS 6.5仍广泛承载关键业务,其内核稳定性与等保适配性成为运维刚需。iRedMail作为集成化邮件套件,提供开箱即用的配置框架,但需手工干预YUM依赖、SELinux上下文、IPv6兼容性及自签名证书

weixin_30654419的博客 429

Web.py 快速上手指南:从入门到实战

Web.py 快速上手指南:从入门到实战 Web.py 是一个轻量级的 Python Web 框架,以其简洁、高效和易用性著称。本文将带你全面了解 Web.py 的核心功能和使用方法,帮助你快速构建 Web 应用。 一、Web.py 概述 Web.py 由 Aaron Swartz 开发,是一个"小而美"的 Python Web 框架。它遵循"简单就是美"的...

gitblog_00472的博客 490

构建Python Web服务实战:使用Web.py框架和MySQL5数据库

Web.py框架为Python Web开发提供了一个简单而强大的基础。它由Aaron Swartz开发,其设计原则是简洁和直接,这使它成为一个非常适合初学者和经验丰富的开发者的框架。Web.py是一个轻量级的Web框架,其核心特点包括:简洁的URL路由:支持直观的URL映射,使得定义路由变得简单明了。内置的模板系统:使用简单的标记语言,不需要复杂的模板语法。支持WSGI:兼容Python Web服务器网关接口标准,这使得它可以在许多不同的服务器上运行。快速开发。

weixin_32925455的博客 1339

封装web.py发送邮件

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_33872660的博客 231

AS3_Cookbook中文完整版

面向功能实现的AS3教程,我是用它入的门,相当不错,现在经常拿它当工具书查。

python3.4实现邮件发送功能

主要为大家详细介绍了python3.4实现邮件发送功能,含带中文附件,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

Web端实现邮件发送

使用java程序向用户邮箱发送文本图片等 发送前准备: 使用POP3(获取)/SMTP(发送)协议 在邮箱上开启此项服务,并获得相关的专用密码 编写前端页面获取相关用户参数: <%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <title>Title</title> </head> <body>

m0_57538148的博客 4188

用python自动复制粘贴excel表里某一列的数据到另一个表中

昨天接到人事小姐姐求助减轻复制粘贴的重复工作量,分享一下代码 半路新手上路 耶 把 2.xlsx 表里的第二列 的数据复制粘贴到 test.xlsx的第一列 python3.6.2 from openpyxl import Workbook from openpyxl import load_workbook from openpyxl.writer.excel import Exc...

weixin_33854644的博客 2万+

web.py的配置

配置PYTHONHOME环境变量 http.conf中 LoadModule wsgi_module modules/mod_wsgi-win32-ap22py27-3.3.so WSGIPythonHome "C:\Python27" AddType text/html .py WSGIScriptAlias / "E:/python/web.py/workspac

fenglvming的专栏 780

串口调试神器诞生记:我是如何用Cursor+AI自动生成C#上位机的(含VSCode插件清单)

本文详细介绍了如何利用Cursor和AI技术快速开发C#上位机程序,实现高效的串口通讯调试。从开发环境搭建到代码自动生成,再到性能优化和功能增强,全面展示了AI辅助开发在串口调试中的实际应用和显著效率提升。

weixin_28340315的博客 299

EGO-Planner文章解读(一)——论文原理和算法实现

详细解读egoplanner论文和代码

fegxg的博客 3986

Python 实现发送、抄送邮件功能

发送邮件 问题 在web.py中,如何发送邮件? 解法 在web.py中使用web.sendmail()发送邮件. web.sendmail('cookbook@webpy.org', 'user@example.com', 'subject', 'message') 如果在web.config中指定了邮件服务器,就会使用该服务器发送邮件,否则,就根据/usr/li...

weixin_30497527的博客 406

备战2025数学建模国赛(算法65):Fisher判别分析

在数学建模竞赛中,我们常常会遇到需要对研究对象进行分类或判断的问题。例如,根据西瓜的各类指标判断其好坏,根据经济数据判断一个国家的发展程度,或根据病人的医学影像特征判断其是否患病。这类“分类判别”问题,是建模竞赛中最常见的题型之一。Fisher判别分析(或称线性判别分析,LDA)作为一种经典的、有监督的降维与分类方法,因其模型简洁、可解释性强、计算高效而备受青睐。

YOLO 421

web.py 0.3 新手指南 - 如何用Gmail发送邮件

问题 如何用Gmail发送邮件? 解法 安装和维护邮件服务器通常是沉闷乏味的。所以如果你有Gmail帐号,就可以使用Gmail做为SMTP服务器来发送邮件,我们唯一要做的就只是在web.config中指定Gmail的用户名和密码。 web.config.smtp_server = 'smtp.gmail.com' web.config.smtp_port = 587 web.confi...

weixin_30527323的博客 128

最新Python爬虫实战(入门爬虫篇)——案例13:某乎热榜数据采集(详细爬虫思路截图+抓包动图演示+完整爬虫代码+详细注释)

本次案例通过Python爬虫技术,成功实现了基于Cookies认证的某乎热榜数据爬取与Excel保存。代码采用模块化设计,包含Cookies解析、HTML请求、结构化解析、Excel持久化等完整流程;通过配置浏览器请求头+Cookies认证,有效突破某乎基础反爬策略,保证请求稳定性。整个爬虫逻辑遵循“Cookies认证 → 页面请求 → HTML解析 → 数据清洗 → 保存到Excel”的标准流程,与需要会话验证的网站爬取范式高度一致。Cookies解析与认证。

努力让自己发光,对的人才能迎着光而来 33万+

基于粒子群优化的PID控制在药液流量控制系统中的应用

本文提出了一种基于粒子群优化(PSO)的PID控制算法,用于药液流量控制系统。系统采用C37控制器和Codesys 2.3编程环境实现,通过传感器实时监测流量、压力和车速,并控制水泵占空比和电动球阀开度来精确调节药液流量。硬件配置包括FT-2000流量传感器、PT-3000压力传感器和MV-500电动球阀等。控制算法将PSO与PID结合,使用ITAE指标优化PID参数,在Codesys中实现了包含PSO优化循环、PID控制等功能的程序模块。该系统通过分层控制策略和智能优化算法,提高了药液流量控制的精度和响应

AI的内部世界的博客 250

web.py 0.3 新手指南 - 发送邮件

问题 在web.py中,如何发送邮件? 解法 在web.py中使用web.sendmail()发送邮件. web.sendmail('cookbook@webpy.org', 'user@example.com', 'subject', 'message') 如果在web.config中指定了邮件服务器,就会使用该服务器发送邮件,否则,就根据/usr/lib/sendmail中的设置发送...

weixin_30323631的博客 145

微信小程序 - request:fail errcode:10011 cronet_error_code:0 error_msg:network change, cancel all task请求报错

微信小程序请求接口,报request:fail errcode:10011是什么原因,uniapp微信小程序request:fail errcode:10011 cronet_error_code:0 error_msg:network change, cancel all task,微信小程序wx.request常规访问接口,有个别用户的接口请求频繁报错,UniApp 微信小程序uni.request请求接口报错:request:fail errcode:10011 的原因分析与解决方案,苹果ios,安卓

🏆 前端领域优质创作者 4566

我的第一个python web开发框架(9)——目录与配置说明

  和老大聊完后,小白回家接收到相关工具函数包后,就按要求开始干活,首先要做的是熟悉配置参数和了解工具函数有哪些实用的工具。   由于这个项目比较简单,所以不用创建那么多分类,只需要api、common、config、log和test五个目录就可以了   打开PyCharm,在前面的Hello World项目里分别创建好上面的目录(如下图),然后将相关文件拷贝到相应文件夹里      co...

weixin_33686714的博客 155

CesiumForUnreal实现鹰眼地图(MiniMap)效果

CesiumForUnreal实现鹰眼地图(MiniMap)效果

专注GIS开发 3951

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

web.py 教程

http://webpy.org/tutorial3.zh-cn http://blog.sina.com.cn/s/blog_69812f770100xrk6.html 安装 可以从 github.com/webpy/webpy 里获得最新的 web.py 执行下列命令抓取 git clone  git://github.com/webpy/webpy.git git

bytxl的专栏 8707

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

python服务器端、客户端的模型,客服端发送请求,服务端进行响应(web.py)

服务器端、客户端的模型,客服端发送的请求,服务端的响应 相当于启动了一个web server install web.py 接口框架用到的包 http://webpy.org/tutorial3.zh-cn 官方网址 http://webpy.org/tutorial3.zh-cn 需要装一个web.py的包,接口就是用web.py来做的,文件上传之类的 可以看一下we...

weixin_30480583的博客 347

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

python发送带有附件的163邮件

问题背景 在开发私人公众号,根据开发公众号的初衷,需要实现python脚本下发送带有附件的163邮件,实现Kindle电子书的自动化推送。 参考 # below original code comes from the link:https://blog.csdn.net/gpf951101/article/details/78909233 # great thanks to this great...

左手是诗,右手是代码。 1931

python 服务器框架 与 web通信_python脚本服务器与web服务器的请求通信

我想翻译一个用arduino制作的程序,在树莓皮上做同样的事情。在arduino中,我有一个带有javascript代码的网页作为web服务器,用来向程序代码发送get请求并告诉它我要做什么(例如,打开一个电磁阀)。为此,我必须让代码理解javascript代码从html网页发送的请求。在这是网页上发送请求的javascript代码的一部分function manual(X){var reques...

weixin_39831001的博客 204

python--httplib模块使用

无意中发现了一个巨牛的人工智能教程,忍不住分享一下给大家。教程不仅是零基础,通俗易懂,而且非常风趣幽默,像看小说一样!觉得太牛了,所以分享给大家。点这里可以跳转到教程。 httplib是一个相对底层的http请求模块,其上有专门的包装模块,如urllib内建模块,goto等第三方模块,但是封装的越高就越不灵活,比如urllib模块里请求错误时就不会返回结果页的内容,只有头信息,对于某些需要检测错...

上帝De助手 11万+
上一篇: python2.X编码问题梳理
下一篇: android学习笔记--环境搭建
上帝De助手
上帝De助手 领域专家: Python技术领域 领域专家: Python技术领域
博客等级 码龄19年 1494粉丝 215原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

上帝De助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值