Comments (8)
I'm going to take a stab at this, thanks for the pointers.
Will report back if I face issues.
from mailmerge.
The spec says that cids must match the addr-spec
, so they must match a valid email address. (Looks like all the SO answers don't match the spec).
Python 3.2+ comes with a cool email.utils.make_msgid
method:
which adds a bit more randomness (and leaks the hostname). But that would still require html parsing to replace hrefs.
Going to pick https://pypi.org/project/html5/, which looks okay-enough for our usecase, and has zero-dependencies.
from mailmerge.
This is a great idea. Here's a Python example.
I think that the only modifications needed would be:
- When attaching an image, add a header
Content-ID: <filename>
- Add an example to the README with an HTML email containing an image
<img src="cid:<filename>"></img>
from mailmerge.
Got html5lib to working, but facing interesting test breakages because the markdown->html and markdown->html->html results in different orderings.
Edit: Got around this by changing tests to parse-and-assert instead of string-equivalence.
- <img alt="python logo not attached" src="http://pluspng.com/img-png/python-logo-png-open-2000.png" /></p></body></html>
+ <img src="http://pluspng.com/img-png/python-logo-png-open-2000.png" alt="python logo not attached" /></p></body></html>
from mailmerge.
When attaching an image, add a header Content-ID:
While this will work for most use cases, weโd have to be careful about attachments from different paths with the same filename. (Then theyโd all get the same content ID!)
To fix this case, we may have to transform all occurrences of a given attachment path to a randomly generated content ID. (With this approach, the message template would specify inline images as <img src=โ./path/to/img.jpgโ />
, and the path would be mapped to the correct content ID.)
from mailmerge.
Have a question regarding the implementation of the transformation.
I was thinking of writing the transformation as a markdown extension, which would work wonderfully, but won't work for the HTML email usecase.
To cover the HTML usecase, I would have to rewrite it with a html-parser (need suggestions here, do we want a heavy dependency like beautifulsoup?) and that kinda makes the markdown extension redundant.
3 options:
- Keep the feature markdown-only (easy implementation, no extra dependencies)
- Implement it twice, once as a markdown extension, and once for direct HTML emails.
- Implement it once, just for HTML, and run the output of the markdown against the HTML transform.
Or is there an easy way to do HTML parsing natively in Python?
from mailmerge.
Hmm, it sounds like the reason for the markdown extension and the reason for possible HTML parsing is handling the "two attachments with same basename" case. The problem is the name clash in Content-Id
, which is the basename of the two attachments.
How about making the Content-Id
value the same as the user-specified attachment path? For example, a markdown formatted email with two attachments could look like this:
To: [email protected]
Attachment: dog.jpg
Attachment: ../dog.jpg
Content-Type: text/markdown
Dog 1 ![dog 1](cid:dog.jpg)
Dog 2 ![dog 2](cid:../dog.jpg)
The same message formatted with plaintext and HTML would be like this:
To: [email protected]
Content-Type: multipart/alternative; boundary="boundary"
MIME-Version: 1.0
Attachment: dog.jpg
Attachment: ../dog.jpg
--boundary
Content-Type: text/plain; charset="us-ascii"
Plaintext dog 1 and dog 2.
--boundary
Content-Type: text/html; charset="us-ascii"
<html><body>
<p><img alt="dog 1" src="cid:dog.jpg" /></p>
<p><img alt="dog 2" src="cid:../dog.jpg" /></p>
</body></html>
from mailmerge.
- Didn't think of letting the user control CID, but it makes sense.
- I am not 100% sure if all valid paths (*nix,windows) will also remain valid CIDs. Will check on this and get back ๐
from mailmerge.
Related Issues (20)
- Recipe for machine-readable messages
- FEATURE MISSING: personal attachments HOT 2
- Block list HOT 1
- Apple Mail with attachments issue (former title: UTF-8 support issue) HOT 11
- Move test dependecies to extras_require
- Debug flag
- mails limit per mail feature HOT 5
- Interactive mode
- Drop Python 2 Support HOT 5
- Change CI to GitHub Actions
- setup.py has "html5" but It has a new name "html5lib"
- Inline images not working in thunderbird? HOT 5
- Crashes on email adresses with illegal characters HOT 2
- Replace `setup.py` with `pyproject.toml`
- Support CSV files with semicolons as separators HOT 3
- Add support for 2FA OAuth authentication HOT 2
- New release on Pipy HOT 1
- No mailmerge_server.conf file in the repository HOT 2
- Load system default SSL cert
- Space at the end of the header row
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mailmerge.