I'm not sure if this will solve for pasting into an email, but I came across this question while looking for how to copy stuff to the clipboard in macOS and have since found a solution that works for me. I figured I'd post it in case anyone else happens across this post with similar needs.
As mentioned in this question's comments, I came across Pyperclip. However I don't want any external dependencies. So, I took a peak at how Pyperclip implemented copy/paste and it's relatively simple. See here.
The short of it is this:
#!/usr/bin/env python3
import subprocess
# copy
def pbcopy(txt):
task = subprocess.Popen(
['pbcopy'],
stdin=subprocess.PIPE,
close_fds=True
)
task.communicate(input=txt.encode('utf-8'))
# paste
def pbpaste():
task = subprocess.Popen(
['pbpaste'],
stdout=subprocess.PIPE,
close_fds=True
)
stdout, stderr = task.communicate()
return(stdout.decode('utf-8'))
Hopefully this solves @MSawers question and if not hopefully someone else will find this useful.