makomailer


Namemakomailer JSON
Version 0.0.3 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-10-23 07:56:53
maintainerNone
docs_urlNone
authorJohannes Bauer
requires_pythonNone
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": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "mako, template, email",
    "author": "Johannes Bauer",
    "author_email": "joe@johannes-bauer.com",
    "download_url": "https://files.pythonhosted.org/packages/81/75/d9a01b5444bf0e54b1ca024fa6f4c0b05174fff44aaf8731efe5c7f31c6a/makomailer-0.0.3.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.3",
    "project_urls": {
        "Download": "https://github.com/johndoe31415/makomailer/archive/v0.0.3.tar.gz",
        "Homepage": "https://github.com/johndoe31415/makomailer"
    },
    "split_keywords": [
        "mako",
        " template",
        " email"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8175d9a01b5444bf0e54b1ca024fa6f4c0b05174fff44aaf8731efe5c7f31c6a",
                "md5": "c546b81960457f4e1ea9207ab6e8f24c",
                "sha256": "0b8dea60daa9faf82ac26b7799a2fa525167d1e9e2692b0891d5f27f69618b44"
            },
            "downloads": -1,
            "filename": "makomailer-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "c546b81960457f4e1ea9207ab6e8f24c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 23309,
            "upload_time": "2024-10-23T07:56:53",
            "upload_time_iso_8601": "2024-10-23T07:56:53.620057Z",
            "url": "https://files.pythonhosted.org/packages/81/75/d9a01b5444bf0e54b1ca024fa6f4c0b05174fff44aaf8731efe5c7f31c6a/makomailer-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-23 07:56:53",
    "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.29617s