I am trying to get your method to work and am having trouble.
Launching linuxcnc from terminal i see errors when the m code is called:
/home/kira/linuxcnc/nc_files/m_codes//M101: 4: import: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 5: import: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 6: from: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 7: from: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 9: arg1: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 10: arg2: not found
/home/kira/linuxcnc/nc_files/m_codes//M101: 14: Syntax error: "elif" unexpected (expecting "then")
It appears python is not being called despite the magic incantation at the top.
I tried the stock #!/usr/bin/env python
as well as #!/usr/bin/python
Mentioned here as well.
forum.linuxcnc.org/10-advanced-configura...-python-script#57764
Running the M101 file as a python script from terminal does indeed send an email. Pretty sweet.
Any idea what could be prohibiting python from being run?