On Tue, May 28, 2019 at 13:59:48 -0400, Doug Stewart wrote:
> when I try your code in octave 5.1.1
> I get
> error: 'py' undefined near line 1 column 8
> error: called from
> email2 at line 1 column 6
Ok, I thought you already had the package installed and loaded.
Add `pkg load pythonic` to the top of the script file.
If you don't have it installed, install it with `pkg`. See
https://gitlab.com/mtmiller/octave-pythonic/blob/master/README.md
If you have `pyeval` but not `py`, then you may have some old code
floating in your environment that you should clean out.
--
mike
My bad it was not loaded!!!
pythonic | 0.0.1+ | /home/doug/octave/pythonic-0.0.1+
Your code now works from inside octave.
When I get the more secure code working we could add it somewhere in octave so users will have a sendmail function.
this works in python
************************
import smtplib, ssl
port = 587 # For starttls
smtp_server = "
smtp.gmail.com"
sender_email = "
address@hidden"
receiver_email = "
address@hidden"
#password = input("Type your password and press enter:")
password='***********'
message = """\
Subject: Hi there
This message is sent from Python."""
context = ssl.create_default_context()
with smtplib.SMTP(smtp_server, port) as server:
server.ehlo() # Can be omitted
server.starttls(context=context)
server.ehlo() # Can be omitted
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)
but this does not work in octave !!!
**************************************
port =
py.int(587) # For starttls
smtp_server = "
smtp.gmail.com"
sender_email = "
address@hidden"
receiver_email = "
address@hidden"
#password = input("Type your password and press enter:")
password="****************";
message = "Subject: Hi there\n\nThis message is sent from Octave using Pythonic.";
context = py.ssl.create_default_context()
server = py.smtplib.SMTP(smtp_server, port);
#server.ehlo() # Can be omitted
server.starttls(context=context)
#server.ehlo() # Can be omitted
server.login(sender_email, password)
server.sendmail(sender_email, receiver_email, message)