• Stars
    star
    134
  • Rank 270,967 (Top 6 %)
  • Language
    Python
  • Created about 8 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Send a notebook as an email

nb2mail - send a jupyter notebook as an email

PyPI version

This repo contains a jupyter nbconvert exporter to convert notebooks to multipart MIME, and a postprocessor to send it via smtp.

Installation

pip install nb2mail

Usage

nb2mail does not do anything by itself. It provides an export format ("mail") and postprocessor ("SendMailPostProcessor"). Please see the nbconvert documentation and example configuration for more information.

Example

To generate a mail and send it later with another process (eg sendmail):

jupyter nbconvert --execute --to mail notebook.ipynb

SMTP Example

To convert and send a mail via gmail, you can set the environment variables and declare a postprocessor with --post:

export [email protected] GMAIL_USER=user GMAIL_PASS="*****"
jupyter nbconvert --to mail --post=nb2mail.SendMailPostProcessor notebook.ipynb

Alternatively, you can configure the SMTP settings in a config file config.py:

c = get_config()
c.NbConvertApp.export_format = 'mail'
c.Exporter.preprocessors = 'nbconvert.preprocessors.ExecutePreprocessor'
c.NbConvertApp.postprocessor_class = 'nb2mail.SendMailPostProcessor'
c.SendMailPostProcessor.recipient = '[email protected]'
c.SendMailPostProcessor.smtp_user = 'user'
c.SendMailPostProcessor.smtp_pass = '*******'
c.SendMailPostProcessor.smtp_addr = 'smtp.gmail.com'
c.SendMailPostProcessor.smtp_port = 587

and then run:

jupyter nbconvert --config config.py demo.ipynb

3rd party email distributor Example

Instead of using SMTP to send emails, one can use 3rd party provider.
This is an example for using mailgun as a 3rd party provider

Configuring Mail Headers

In the notebook metadata, you can set mail headers by adding a nb2mail block:

"nb2mail": {
"attachments": [
    "business_report_attachment.xlsx"
],
"From": "[email protected]",
"To": "[email protected], [email protected]",
"Subject": "Business Report"
}

You can specify multiple recipients by seperating them with commas.

Disabling Pilcrows

Since CSS doesn't render the same in email, you may want to disable the pilcrows after each section.

c.MailExporter.anchor_link_text = '' # disable pilcrow, requires nbconvert >= 5.2

Refences

TODO

  • Prerender Math - no js in email

  • Prettier templates

  • Plotly - here is a workaround:

    # py.iplot(fig, filename=β€˜dcm_ctr_subplots’)
    # The above line is what you normally use to show your plots in the notebook
    # You no longer need that and just need the stuff below
    
    from IPython.display import Image
    
    py.image.save_as(fig, filename='yahoo_dcm_ctr_subplots.png')
    Image('yahoo_dcm_ctr_subplots.png')
    

More Repositories

1

grpc

gRPC clients and servers in R
C++
67
star
2

tron

R package for easy logging
R
39
star
3

stackoverflow

An R package for snippets from stackoverflow
R
28
star
4

AWR.Athena

Short R Wrapper for Athena JDBC connections
R
23
star
5

jupyterlab-theme-simple-extension

A simpler theme from a more civilized time
CSS
18
star
6

Rip46

R package for IP addresses
C++
15
star
7

vp

Convert P Values to Video Poker hands
R
15
star
8

alerts

strip tracking and syndicate google alerts
Python
11
star
9

binomialbcp

R package for binomial change point detection
R
10
star
10

reader.htm

A Federated Wiki frontend
HTML
8
star
11

chad

An R package for lightweight acceptance testing
R
8
star
12

aws-batch

A jenkins plugin for submitting jobs to AWS batch // use the official one now
Java
8
star
13

nfultz.github.io

my homepage
HTML
8
star
14

osc1337

Terminal graphics for R
R
7
star
15

standup.py

Prints out open jira tickets
Python
7
star
16

hashtrick

R package implementing the hash trick using the OpenSSL library.
R
6
star
17

pumpkin

Turns an EC2 node into a πŸŽƒ
Shell
6
star
18

shoegazer

refactoring stargazer
R
5
star
19

freecell

a solitaire card game (fork)
Shell
4
star
20

RcppJson

json for Rcpp
C++
4
star
21

ht

Tiny Hash Table for R
R
4
star
22

hilite

mirror from sourceforge
C
4
star
23

lafd

data angels project for lafd
R
4
star
24

QED

mirror of http://www.math.ucla.edu/~tao/QED/
HTML
4
star
25

resume_template

a resume template in markdown
CSS
4
star
26

askgitdbi

a DBI wrapper around askgit
R
4
star
27

suicide

timeouts for R scripts
R
3
star
28

pynchon_names.py

Python
3
star
29

codetrack

A lightweight ticket app for project management
PHP
3
star
30

pylrqp

Low Rank Quadratic Programming
C
3
star
31

octosqlR

A DBI wrapper around octosql
R
3
star
32

todo.nfultz.com

😫
HTML
3
star
33

mlstump

Python
3
star
34

ffss

Pretty printer for tables and such
Python
3
star
35

whatstat

R
3
star
36

stogie

Go
3
star
37

makesnippets

A snippet manager implemented in GNU make
Makefile
3
star
38

c2d4u.tools

in-R installer for c2d4u
R
2
star
39

rem

Shell
2
star
40

nbws

Newsbeuter websocket wrapper
Python
2
star
41

big3

Makefile
2
star
42

Intro_Dueto

~PyDataLA 2020~ talk
HTML
2
star
43

cns

Color Naming System for R
R
2
star
44

colinux

Run linux on win32 [mirror]
C
2
star
45

gossipbot

Posts silicon beach gossip to slack
Python
2
star
46

sponsorify

Shell script to add sponsor metadata to a GH repo
Shell
2
star
47

conkyhttpd

Conky over the web
C
2
star
48

worr-css

Pure(ish) CSS stylesheet for Warnier-Orr diagrams
CSS
2
star
49

zigdf

A Data Frame in zig
Zig
2
star
50

learnSampling

R
2
star
51

fuego

Fire for R
R
2
star
52

logparserwinedocker

WindowsXP LogParser, in wine, in docker
Shell
2
star
53

compiz_session

Run compiz w/o ubuntu desktop extensions
Makefile
2
star
54

AWR.Redshift

R Wrapper to Redshift JDBC driver
R
2
star
55

ec2instances.info

An R package containing info on ec2 instances.
R
2
star
56

easyslider

Easier sliders for Shiny
R
2
star
57

cover_sandwich

a web site about cover sandwiches
HTML
1
star
58

mortem-bak

Automated backups of Jupiter Hell mortems
Shell
1
star
59

remind

Mirror of remind
C
1
star
60

murderboard

HTML
1
star
61

advent2021

R
1
star
62

DBIsqldf

fork of sqldf
R
1
star
63

greasemonkey

old greasemonkey scripts
JavaScript
1
star
64

glmnet-mirror

mirror of glmnet
Fortran
1
star
65

AWR.Lambda

R wrapper for AWS Lambda
R
1
star
66

hacktoberfy

Adds hacktoberfest label to all public repos
Batchfile
1
star
67

r-nfultz

A backup of links shared on r/nfultz
Shell
1
star
68

minepyRcpp

Demo package using minepy
C
1
star
69

zcss

Css for lattice and ggplot2
R
1
star
70

rle.py

run length encoding using generators
Python
1
star
71

stat.extend

R
1
star
72

finddprior

Given box constraints, find a dirichlet prior when estimating proportions.
R
1
star
73

KMS2

AWR.KMS Rcpp Remix
C++
1
star
74

hgrecap

MCMC for hypergeometric model of size
C++
1
star
75

hiveuberjar

R Wrapper for Hive JDBC Uber Jar
R
1
star
76

omnitab

backup of omnitab 80 | https://www.nist.gov/itl/sed/omnitab-80
Fortran
1
star
77

wiki-plugin-linkdump

A linkdump bookmarklet for Federated Wiki
CoffeeScript
1
star
78

AWR.Batch

R package for submitting jobs to AWS Batch
R
1
star
79

ultrafilter

XSLT
1
star
80

drift

my 2023 7drl
Python
1
star
81

naughtyurl

C
1
star
82

static

static local variables for R
R
1
star
83

AWR.S3

R
1
star
84

rstudio-debian

1
star
85

stlogging

R port of stata log using
R
1
star
86

csp24-tutorial

Julia
1
star
87

ntk_corpus

HTML
1
star
88

UclaAnnoyances

A UBlock filter list for UCLA staff and students
1
star