How to send E-mail without an external SMTP server ?

Leo Kislov Leo.Kislov at gmail.com
Mon Oct 16 06:10:31 EDT 2006



On Oct 16, 2:04 am, "fdu.xia... at gmail.com" <fdu.xia... at gmail.com>
wrote:
> It's not safe if I have to use login method explicitly by which I have
> to put my username and password in the script. I have also tried the
> Unix command 'mail', but without success, either. I could use 'mail' to
> send an E-mail to the user on the server, but I couldn't send an E-mail
> to an external E-mail server. I realized that it may because the port 25
> outgoing connections are blocked, so I gave up. I will have to login
> periodically to check the status of the jobs:-(

Using username password is safe as long as you trust system admin, you
just need to make your script readable only to you. Or even better put
the username and password in a separate file. There is also a way to
limit damage in case you don't trust admin, you just need to get auth
token. Start smtp session and set debug level(True), use login method
and see the token:

send: 'AUTH PLAIN <HERE IS THE TOKEN>\r\n'
reply: '235 2.7.0 Accepted\r\n'
reply: retcode (235); Msg: 2.7.0 Accepted

Then put the token in a file readable only to you, and from now on
instead of login() method use docmd('AUTH PLAIN',"<YOUR TOKEN FROM
FILE>). If the token is stolen, the thief can only send mail from your
account but won't be able to login with password.




More information about the Python-list mailing list