makomailer


Namemakomailer JSON
Version 0.0.2 PyPI version JSON
download
home_pagehttps://github.com/johndoe31415/makomailer
SummaryVersatile CLI-based tool to send mails rendered from Mako templates, supporting SMTP and IMAP
upload_time2024-01-21 10:30:38
maintainer
docs_urlNone
authorJohannes Bauer
requires_python
licensegpl-3.0
keywords mako template email
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # makomailer
makomailer is a tool that can send emails from the command line easily using
versatile Mako templates. The sent mails can be delivered via SMTP and can also
be stored in a "Sent" folder of an IMAP server. Source data is provided in JSON
form and inclusion of Python code to augment the rendering of the script is
easily possible by specifying Python "code" hooks that are either called once
per JSON-file or once per email to be sent.

## Example
An example can be seen when simply calling:

```
$ ./makomailer.py test_data.json test_email.email
From: Jöhannes Bauer <joe@home.net>
To: Chris Foo <foo@invalid.net>
Subject: Celebräte my 43rd birthday
Date: Tue, 07 Mar 2023 00:33:42 +0100
User-Agent: https://github.com/johndoe31415/makomailer 0.0.1rc0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0

Hey there Mr. Chris,

it's time to celebrate my 43rd birthday. As you have discussed with me,
I'm getting a present from you. Wow! Also note that this is a very long
line and it should, in the final email, be broken up into compliant-
length lines (72 chars per line).

Also I want to celebrate umlauts on my birthday. Have some: =C3=A4=C3=B6=C3=
=BC=C3=84=C3=96=C3=9C

I'm looking forward to the Box of chocolates.

Kind regards,
Johannes Bauer
[...]
```

This is the (abbreviated) JSON file that was used as input:

```json
{
	"global": {
		"birthday":		"1980-01-01",
		"year":			2023
	},
	"hooks_once": [
		{
			"filename": "test_preprocess.py"
		}
	],
	"hooks": [
		{
			"filename": "test_preprocess.py"
		}
	],
	"individual": [
		{
			"to": {
				"email":				"foo@invalid.net",
				"firstname":			"Chris",
				"lastname":				"Foo",
				"salutation_prefix":	"Mr.",
				"salutation":			"informal"
			},
			"presents": [
				"Box of chocolates"
			]
		}
	]
}
```

All `global` data is visible from within the template as the `g` variable. Each
rendered email has its individual `i` variable. This data is then used to
render the template, such as in this case:

```mail
From: ${h.mail_addr_format("joe@home.net", "Jöhannes Bauer")}
To: ${h.mail_addr_format(i["to"]["email"], i["to"]["firstname"] + " " + i["to"]["lastname"])}
Subject: Celebräte my ${nth(g["age"])} birthday

%if i["to"]["salutation"] == "formal":
Dear\
%else:
Hey there\
%endif
%if "salutation_prefix" in i["to"]:
 ${i["to"]["salutation_prefix"]}\
%endif
%if i["to"]["salutation"] == "formal":
 ${i["to"]["lastname"]},
%else:
 ${i["to"]["firstname"]},
%endif

it's time to celebrate my ${nth(g["age"])} birthday. As you have discussed with me, I'm getting ${"a present" if (present_cnt == 1) else f"{present_cnt} presents"} from you. ${"Wow!" if (present_cnt > 0) else "Sad."} Also note that this is a very long line and it should, in the final email, be broken up into compliant-length lines (72 chars per line).
```

Note that there is also Python code called:

```python3
def execute_once(self):
	self._template_vars["g"]["birthday"] = self._iso_date_parse(self._template_vars["g"]["birthday"])
	self._template_vars["g"]["age"] = self._template_vars["g"]["year"] - self._template_vars["g"]["birthday"].year

def execute_each(self):
	self._template_vars["nth"] = self._nth
	self._template_vars["present_cnt"] = len(self._template_vars["i"]["presents"])
```

If the third command line option (`via`) is omitted, the mails are simply
printed out on the command line. If a `via` option is specified, it needs to
contain details about how/where to send the emails to.

Note that makomailer, by default, also stores if an email could successfully be
delivered so that if there is an error (e.g., connection abort) the mails that
were successfully delivered already are not re-delivered on a second run.

## Licsense
GNU GPL-3.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/johndoe31415/makomailer",
    "name": "makomailer",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "mako,template,email",
    "author": "Johannes Bauer",
    "author_email": "joe@johannes-bauer.com",
    "download_url": "https://files.pythonhosted.org/packages/f3/67/6d20948bbf8bc05f392c13f7d4cd638ab0483c82a11c2536a8748f1e1da9/makomailer-0.0.2.tar.gz",
    "platform": null,
    "description": "# makomailer\nmakomailer is a tool that can send emails from the command line easily using\nversatile Mako templates. The sent mails can be delivered via SMTP and can also\nbe stored in a \"Sent\" folder of an IMAP server. Source data is provided in JSON\nform and inclusion of Python code to augment the rendering of the script is\neasily possible by specifying Python \"code\" hooks that are either called once\nper JSON-file or once per email to be sent.\n\n## Example\nAn example can be seen when simply calling:\n\n```\n$ ./makomailer.py test_data.json test_email.email\nFrom: J\u00f6hannes Bauer <joe@home.net>\nTo: Chris Foo <foo@invalid.net>\nSubject: Celebr\u00e4te my 43rd birthday\nDate: Tue, 07 Mar 2023 00:33:42 +0100\nUser-Agent: https://github.com/johndoe31415/makomailer 0.0.1rc0\nContent-Type: text/plain; charset=\"utf-8\"\nContent-Transfer-Encoding: quoted-printable\nMIME-Version: 1.0\n\nHey there Mr. Chris,\n\nit's time to celebrate my 43rd birthday. As you have discussed with me,\nI'm getting a present from you. Wow! Also note that this is a very long\nline and it should, in the final email, be broken up into compliant-\nlength lines (72 chars per line).\n\nAlso I want to celebrate umlauts on my birthday. Have some: =C3=A4=C3=B6=C3=\n=BC=C3=84=C3=96=C3=9C\n\nI'm looking forward to the Box of chocolates.\n\nKind regards,\nJohannes Bauer\n[...]\n```\n\nThis is the (abbreviated) JSON file that was used as input:\n\n```json\n{\n\t\"global\": {\n\t\t\"birthday\":\t\t\"1980-01-01\",\n\t\t\"year\":\t\t\t2023\n\t},\n\t\"hooks_once\": [\n\t\t{\n\t\t\t\"filename\": \"test_preprocess.py\"\n\t\t}\n\t],\n\t\"hooks\": [\n\t\t{\n\t\t\t\"filename\": \"test_preprocess.py\"\n\t\t}\n\t],\n\t\"individual\": [\n\t\t{\n\t\t\t\"to\": {\n\t\t\t\t\"email\":\t\t\t\t\"foo@invalid.net\",\n\t\t\t\t\"firstname\":\t\t\t\"Chris\",\n\t\t\t\t\"lastname\":\t\t\t\t\"Foo\",\n\t\t\t\t\"salutation_prefix\":\t\"Mr.\",\n\t\t\t\t\"salutation\":\t\t\t\"informal\"\n\t\t\t},\n\t\t\t\"presents\": [\n\t\t\t\t\"Box of chocolates\"\n\t\t\t]\n\t\t}\n\t]\n}\n```\n\nAll `global` data is visible from within the template as the `g` variable. Each\nrendered email has its individual `i` variable. This data is then used to\nrender the template, such as in this case:\n\n```mail\nFrom: ${h.mail_addr_format(\"joe@home.net\", \"J\u00f6hannes Bauer\")}\nTo: ${h.mail_addr_format(i[\"to\"][\"email\"], i[\"to\"][\"firstname\"] + \" \" + i[\"to\"][\"lastname\"])}\nSubject: Celebr\u00e4te my ${nth(g[\"age\"])} birthday\n\n%if i[\"to\"][\"salutation\"] == \"formal\":\nDear\\\n%else:\nHey there\\\n%endif\n%if \"salutation_prefix\" in i[\"to\"]:\n ${i[\"to\"][\"salutation_prefix\"]}\\\n%endif\n%if i[\"to\"][\"salutation\"] == \"formal\":\n ${i[\"to\"][\"lastname\"]},\n%else:\n ${i[\"to\"][\"firstname\"]},\n%endif\n\nit's time to celebrate my ${nth(g[\"age\"])} birthday. As you have discussed with me, I'm getting ${\"a present\" if (present_cnt == 1) else f\"{present_cnt} presents\"} from you. ${\"Wow!\" if (present_cnt > 0) else \"Sad.\"} Also note that this is a very long line and it should, in the final email, be broken up into compliant-length lines (72 chars per line).\n```\n\nNote that there is also Python code called:\n\n```python3\ndef execute_once(self):\n\tself._template_vars[\"g\"][\"birthday\"] = self._iso_date_parse(self._template_vars[\"g\"][\"birthday\"])\n\tself._template_vars[\"g\"][\"age\"] = self._template_vars[\"g\"][\"year\"] - self._template_vars[\"g\"][\"birthday\"].year\n\ndef execute_each(self):\n\tself._template_vars[\"nth\"] = self._nth\n\tself._template_vars[\"present_cnt\"] = len(self._template_vars[\"i\"][\"presents\"])\n```\n\nIf the third command line option (`via`) is omitted, the mails are simply\nprinted out on the command line. If a `via` option is specified, it needs to\ncontain details about how/where to send the emails to.\n\nNote that makomailer, by default, also stores if an email could successfully be\ndelivered so that if there is an error (e.g., connection abort) the mails that\nwere successfully delivered already are not re-delivered on a second run.\n\n## Licsense\nGNU GPL-3.\n",
    "bugtrack_url": null,
    "license": "gpl-3.0",
    "summary": "Versatile CLI-based tool to send mails rendered from Mako templates, supporting SMTP and IMAP",
    "version": "0.0.2",
    "project_urls": {
        "Download": "https://github.com/johndoe31415/makomailer/archive/v0.0.2.tar.gz",
        "Homepage": "https://github.com/johndoe31415/makomailer"
    },
    "split_keywords": [
        "mako",
        "template",
        "email"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "f3676d20948bbf8bc05f392c13f7d4cd638ab0483c82a11c2536a8748f1e1da9",
                "md5": "a79cfc2f72e3308d76d07bd1b80a84b9",
                "sha256": "d73e5cd8dacdab18b6f18498b9c306d3a6eb1fb391bad5cafec75ff8d865aada"
            },
            "downloads": -1,
            "filename": "makomailer-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a79cfc2f72e3308d76d07bd1b80a84b9",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23037,
            "upload_time": "2024-01-21T10:30:38",
            "upload_time_iso_8601": "2024-01-21T10:30:38.390215Z",
            "url": "https://files.pythonhosted.org/packages/f3/67/6d20948bbf8bc05f392c13f7d4cd638ab0483c82a11c2536a8748f1e1da9/makomailer-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-01-21 10:30:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "johndoe31415",
    "github_project": "makomailer",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "makomailer"
}
        
Elapsed time: 0.17956s