本文整理汇总了Python中pyramid_mailer.mailer.Mailer类的典型用法代码示例。如果您正苦于以下问题:Python Mailer类的具体用法?Python Mailer怎么用?Python Mailer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Mailer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: ThreadMailer
class ThreadMailer(threading.Thread):
"""
인덱스 추가/삭제를 위한 쓰레드
"""
def __init__(self):
threading.Thread.__init__(self)
self.queue = Queue.Queue()
self.mailer = Mailer(host="localhost")
def send(self, msg):
self.queue.put(msg)
def run(self):
while True:
# 큐에서 작업을 하나 가져온다
msg = self.queue.get()
self.mailer.send(msg)
log.info(msg.subject)
transaction.commit()
log.info("MAIL COMMITTED!")
# 작업 완료를 알리기 위해 큐에 시그널을 보낸다.
self.queue.task_done()
def end(self):
self.queue.join()
开发者ID:theun,项目名称:in.nuribom.com,代码行数:27,代码来源:admin.py
示例2: email
def email(subject=None, recipients=None, body=None):
mailer = Mailer(host='192.168.101.5')
message = Message(subject=subject,
sender='[email protected]',
recipients=recipients,
html=body)
mailer.send_immediately(message)
开发者ID:msabramo,项目名称:Doula,代码行数:8,代码来源:notifications.py
示例3: test_send_immediately_and_fail_silently
def test_send_immediately_and_fail_silently(self):
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Message
mailer = Mailer()
msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")
mailer.send_immediately(msg, True)
开发者ID:DerRechner,项目名称:pyramid_mailer,代码行数:10,代码来源:tests.py
示例4: test_send
def test_send(self):
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Message
mailer = Mailer()
msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")
mailer.send(msg)
开发者ID:rpatterson,项目名称:pyramid_mailer,代码行数:10,代码来源:tests.py
示例5: test_send_immediately_and_fail_silently
def test_send_immediately_and_fail_silently(self):
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Message
mailer = Mailer(host="localhost", port="28322")
msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")
result = mailer.send_immediately(msg, True)
self.assertEqual(result, None)
开发者ID:rpatterson,项目名称:pyramid_mailer,代码行数:11,代码来源:tests.py
示例6: test_bcc_without_recipients
def test_bcc_without_recipients(self):
from pyramid_mailer.message import Message
from pyramid_mailer.mailer import Mailer
msg = Message(subject="testing", sender="[email protected]", body="testing", bcc=["[email protected]"])
mailer = Mailer()
msgid = mailer.send(msg)
response = msg.to_message()
self.assertFalse("Bcc: [email protected]" in text_type(response))
self.assertTrue(msgid)
开发者ID:kristianbenoit,项目名称:pyramid_mailer,代码行数:12,代码来源:test_message.py
示例7: test_send_without_body
def test_send_without_body(self):
from pyramid_mailer.message import Message
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.exceptions import InvalidMessage
msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"])
mailer = Mailer()
self.assertRaises(InvalidMessage, mailer.send, msg)
msg.html = "<b>test</b>"
mailer.send(msg)
开发者ID:kristianbenoit,项目名称:pyramid_mailer,代码行数:15,代码来源:test_message.py
示例8: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application. """
config = Configurator(settings=settings)
#set up beaker session
session_factory = session_factory_from_settings(settings)
config.set_session_factory(session_factory)
# add security tweens
# config.add_tween('aws_demo.tweens.clickjacking.clickjacking_factory')
# config.add_tween('aws_demo.tweens.secure_headers.secure_headers_factory')
config.registry['mailer'] = Mailer.from_settings(settings=settings)
# modify the built in json renderer to serialize dates properly
json_date_renderer = JSON()
json_date_renderer.add_adapter(datetime.datetime, new_datetime_adapter)
# set .html renderer to allow mako templating
config.add_renderer('.html', 'pyramid.mako_templating.renderer_factory')
config.add_renderer('.htm', 'pyramid.mako_templating.renderer_factory')
config.add_renderer('json', json_date_renderer)
config.add_static_view('static', 'static', cache_max_age=3600)
# login / registration
config.add_route('index_view', '/')
config.scan()
return config.make_wsgi_app()
开发者ID:k-wiens,项目名称:Blah,代码行数:34,代码来源:__init__.py
示例9: main
def main(argv=sys.argv):
if len(argv) != 2:
usage(argv)
config_uri = argv[1]
setup_logging(config_uri)
settings = get_appsettings(config_uri)
engine = engine_from_config(settings, "sqlalchemy.")
mailer = Mailer.from_settings(settings)
DBSession.configure(bind=engine)
rootFolder = settings["reports.folder"]
request = Request.blank("/", base_url=settings["reports.app.url"])
env = bootstrap(config_uri, request=request)
request = env["request"]
try:
remove_groups(request)
remove_reports(request)
handleRootFolder(request, rootFolder)
# email_users(request, mailer)
email_admin_users(request, mailer)
transaction.commit()
except Exception as e:
transaction.abort()
stack = traceback.format_exc()
body = "Got an exception while processing reports: %s\n\n%s" % (e, stack)
message = Message(
subject="Famoso Reports - failed to process",
sender="[email protected]",
recipients=["[email protected]"],
body=body,
)
mailer.send_immediately(message)
开发者ID:robottaway,项目名称:Famoso-Reports,代码行数:34,代码来源:process_new_reports.py
示例10: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
engine = engine_from_config(settings, "sqlalchemy.")
DBSession.configure(bind=engine)
Base.metadata.bind = engine
authn_policy = AuthTktAuthenticationPolicy("sosecret", callback=groupfinder, hashalg="sha512")
authz_policy = ACLAuthorizationPolicy()
config = Configurator(settings=settings, root_factory="webapp.models.RootFactory")
config.set_authentication_policy(authn_policy)
config.set_authorization_policy(authz_policy)
config.registry["mailer"] = Mailer.from_settings(settings)
config.add_static_view("static", "static", cache_max_age=3600)
config.add_route("index", "/")
config.add_route("login", "/login")
config.add_route("logout", "/logout")
config.add_route("registration", "/registration")
# config.add_route('end_reg', '/activate/{a_code}')
config.add_route("verify", "/verify/{code}")
# config.add_route('confirm', '/confirm')
config.add_route("content", "/content/{id}")
config.add_route("about", "/about")
config.add_route("pay", "/pay")
config.add_route("preview", "/preview")
config.add_route("bundle_preview", "/bundle_preview")
config.add_route("b_content", "/bonus/{id}")
config.add_route("bundle", "/bundle/{id}")
config.add_route("account", "/account/{parameters}")
config.scan()
return config.make_wsgi_app()
开发者ID:PashaShulga,项目名称:webapp,代码行数:31,代码来源:__init__.py
示例11: main
def main(global_config, **settings):
"""
This function returns a Pyramid WSGI application.
"""
# the database session:
engine = engine_from_config(settings, 'sqlalchemy.')
DBSession.configure(bind=engine)
Base.metadata.bind = engine
# session_factory = session_factory_from_settings(settings)
config = Configurator(
settings=settings,
root_factory=get_root,
authentication_policy=GyAuthenticationPolicy(),
authorization_policy=GyAuthorizationPolicy(),
session_factory = session_factory_from_settings(settings),
request_factory = GyRequest,
)
config.add_static_view('static', 'static', cache_max_age=3600)
# config.include('pyramid_mailer')
mailer = Mailer.from_settings(settings)
config.registry['mailer'] = mailer
config.include('gy.core')
config.include('gy.blog')
config.add_notfound_view(gy_not_found, append_slash=True)
config.scan()
return config.make_wsgi_app()
开发者ID:kratenko,项目名称:gy,代码行数:33,代码来源:__init__.py
示例12: mailer_factory_from_settings
def mailer_factory_from_settings(settings, prefix='mail.'):
"""
Factory function to create a Mailer instance from settings.
Equivalent to **Mailer.from_settings**
:versionadded: 0.2.2
"""
return Mailer.from_settings(settings, prefix)
开发者ID:AnneGilles,项目名称:pyramid_mailer,代码行数:8,代码来源:__init__.py
示例13: test_send
def test_send(self):
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Attachment
from pyramid_mailer.message import Message
mailer = Mailer()
msg = Message(subject="testing",
sender="[email protected]",
recipients=["[email protected]"],
body="test")
msg.attach(Attachment('test.txt',
data=b"this is a test",
content_type="text/plain"))
mailer.send(msg)
开发者ID:lorenzogil,项目名称:pyramid_mailer,代码行数:17,代码来源:tests.py
示例14: mailer_factory_from_settings
def mailer_factory_from_settings(settings, prefix='mail.'):
"""
Factory function to create a Mailer instance from settings.
Equivalent to :meth:`pyramid_mailer.mailer.Mailer.from_settings`.
:versionadded: 0.2.2
"""
return Mailer.from_settings(settings, prefix)
开发者ID:SalesSeek,项目名称:pyramid_mailer,代码行数:8,代码来源:__init__.py
示例15: main
def main(global_config, **settings):
""" This function returns a Pyramid WSGI application.
"""
authentication_policy = AuthTktAuthenticationPolicy('seekrit', callback=groupfinder)
authorization_policy = ACLAuthorizationPolicy()
engine = engine_from_config(settings, prefix='sqlalchemy.')
db_maker = sessionmaker(bind=engine)
settings['rel_db.sessionmaker'] = db_maker
config = Configurator(settings=settings,
root_factory='scielobooks.resources.RootFactory',
authentication_policy=authentication_policy,
authorization_policy=authorization_policy,
request_factory=MyRequest,
renderer_globals_factory=renderer_globals_factory)
config.include(pyramid_zcml)
config.load_zcml('configure.zcml')
config.include('pyramid_mailer')
config.include('pyramid_celery')
config.registry['mailer'] = Mailer.from_settings(settings)
config.registry['app_version'] = APP_VERSION
db_uri = settings['db_uri']
conn = couchdbkit.Server(db_uri)
config.registry.settings['db_conn'] = conn
config.add_subscriber(add_couch_db, NewRequest)
config.scan('scielobooks.models')
initialize_sql(engine)
if settings['serve_static_files'] == 'true':
config.add_static_view(name='static', path='static')
config.add_static_view('deform_static', 'deform:static')
config.add_static_view('/'.join((settings['db_uri'], settings['db_name'])), 'scielobooks:database')
config.add_static_view(settings['fileserver_url'], 'scielobooks:fileserver')
config.add_view(custom_forbidden_view, context=Forbidden)
config.add_translation_dirs('scielobooks:locale/')
config.set_locale_negotiator(custom_locale_negotiator)
my_session_factory = UnencryptedCookieSessionFactoryConfig('itsaseekreet')
config.set_session_factory(my_session_factory)
application = config.make_wsgi_app()
try:
if settings.get('newrelic.enable', 'False').lower() == 'true':
newrelic.agent.initialize(os.path.join(APP_PATH, '..', 'newrelic.ini'), settings['newrelic.environment'])
return newrelic.agent.wsgi_application()(application)
else:
return application
except IOError:
config.registry.settings['newrelic.enable'] = False
return application
开发者ID:fabiobatalha,项目名称:scielobooks,代码行数:58,代码来源:__init__.py
示例16: profile
def profile(request):
"""
View profile page.
"""
user = User.get(request.session['login'])
if request.method =='POST':
flashError = "Sorry dude : wrong password"
if not request.POST['initPassword'].strip():
request.session.flash('No password provided')
return {'user':user}
elif not bcrypt.hashpw(request.POST['initPassword'].encode('utf-8'), user.password) == user.password:
request.session.flash(flashError)
return {'user':user}
if request.POST['submitDelete']:
mailer = Mailer()
message = Message(subject="Account deleted",
sender=settings['mail_from'],
recipients=[user.mail],
body="Your account have been deleted")
mailer.send_immediately(message, fail_silently=False)
user.delete()
request.session.delete()
return HTTPFound(location=request.route_path('home'))
if request.POST['newPassword'].strip():
if request.POST['newPassword'] == request.POST['confirmPassword']:
password = bcrypt.hashpw(request.POST['newPassword'].encode('utf-8'), bcrypt.gensalt())
user.password = password
else:
request.session.flash(u"Password not confirm")
return {'user' : user}
user.name = request.POST['name']
user.description = request.POST['description']
user.mail = request.POST['email']
user.save()
request.session.flash(u"Modification saved !")
return {'user':user}
开发者ID:cyplp,项目名称:wsgiwar2013,代码行数:44,代码来源:views.py
示例17: contato
def contato(request):
"""Contato"""
# Import smtplib for the actual sending function
import smtplib
esquema = FormContato().bind(request=request)
esquema.title = "Entre em contato com o Cuidando"
form = deform.Form(esquema, buttons=('Enviar',))
if 'Enviar' in request.POST:
# Validação do formulário
try:
form.validate(request.POST.items())
except deform.ValidationFailure as e:
return {'form': e.render()}
#sender = request.POST.get("email")
#receivers = ['[email protected]']
#message = request.POST.get("assunto")
try:
#s = smtplib.SMTP( [host [, port [, local_hostname]]] )
#s = smtplib.SMTP('pop.mail.yahoo.com.br',587)
#smtpObj.sendmail(sender, receivers, message)
#s.quit()
#mailer = get_mailer(request)
mailer = Mailer()
message = Message(
subject=request.POST.get("assunto"),
sender= request.POST.get("email"), #"[email protected]",
recipients=['[email protected]'],
body=request.POST.get("mensagem")
)
mailer.send(message)
transaction.commit()
print "Successfully sent email"
#except SMTPException:
except:
print "Error: unable to send email"
return HTTPFound(location=request.route_url('inicial'))
else:
# Apresentação do formulário
return {'form': form.render()}
开发者ID:COLAB-USP,项目名称:cuidando-experimentos,代码行数:44,代码来源:views.py
示例18: __init__
def __init__(self, *args, **settings):
if len(args) == 1:
# regular app
app = None
else:
app = args[0]
self.initialize_settings(app, settings)
# db configuration
db_factory_name = settings.get('db_factory_name', 'sql')
if db_factory_name not in db_factories:
raise Exception("Invalid db_factory_name: %s" % db_factory_name)
settings['db_session_id'], self.db = db_factories[db_factory_name](settings, self) # noqa
self.setup_autouserfinder(settings)
# start pyramid application configuration
config = Configurator(settings=settings, request_factory=Request)
try:
import pyramid_chameleon # noqa
config.include('pyramid_chameleon')
except ImportError:
pass
self.setup_plugins(config, settings)
from factored.views import auth_chooser, notfound
config.add_route('auth', self.base_auth_url)
config.add_view(auth_chooser, route_name='auth',
renderer='templates/layout.pt')
# setup template customization registration
if TEMPLATE_CUSTOMIZATIONS not in config.registry:
config.registry[TEMPLATE_CUSTOMIZATIONS] = {}
# static paths for resources
self.static_path = os.path.join(self.base_auth_url, 'authstatic')
config.add_static_view(name=self.static_path,
path='factored:static')
config.add_notfound_view(notfound, append_slash=True)
# add some things to registry
config.registry['mailer'] = Mailer.from_settings(settings)
config.registry['settings'] = self.__dict__
config.registry['formtext'] = nested_settings(
get_settings(settings, 'formtext.'))
config.registry['app'] = self
config.scan()
self.config = config
self.registry = self.config.registry
try:
self.app.config.registry['factored'] = self
except:
pass
self.pyramid = config.make_wsgi_app()
开发者ID:wildcardcorp,项目名称:factored,代码行数:56,代码来源:app.py
示例19: test_send_to_queue
def test_send_to_queue(self):
import os
import tempfile
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Message
test_queue = os.path.join(tempfile.gettempdir(), "test_queue")
for dir in ("cur", "new", "tmp"):
try:
os.makedirs(os.path.join(test_queue, dir))
except OSError:
pass
mailer = Mailer(queue_path=test_queue)
msg = Message(subject="testing", sender="[email protected]", recipients=["[email protected]"], body="test")
mailer.send_to_queue(msg)
开发者ID:rpatterson,项目名称:pyramid_mailer,代码行数:20,代码来源:tests.py
示例20: test_send_immediately_multipart
def test_send_immediately_multipart(self):
from pyramid_mailer.mailer import Mailer
from pyramid_mailer.message import Message
mailer = Mailer()
utf_8_encoded = b('mo \xe2\x82\xac')
utf_8 = utf_8_encoded.decode('utf_8')
text_string = utf_8
html_string = '<p>'+utf_8+'</p>'
msg = Message(subject="testing",
sender="[email protected]",
recipients=["[email protected]"],
body=text_string,
html=html_string)
mailer.send_immediately(msg, True)
开发者ID:lorenzogil,项目名称:pyramid_mailer,代码行数:20,代码来源:tests.py
注:本文中的pyramid_mailer.mailer.Mailer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论