By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,909 Members | 1,996 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,909 IT Pros & Developers. It's quick & easy.

very small python smtpish send

P: n/a
Anyone know of a small Python script that acts as a slimmed down smtp
server (just sends from the local machine)? I currently use a smtp
server for sending email reports from machines, but as machines travel
outside of our lan, the smtp server refuses to relay their messages. So,
I thought it would be better if each machine had its own little mail
sender this way, it could continue reporting no matter where it was located.

These are all Windows machines... is there a Windows equivalent to
'stdin | mail -s "Subject" em***@email.com' that comes on most Unix
machines?
Jul 18 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
On Fri, 8 Oct 2004, Brad Tilley wrote:
Anyone know of a small Python script that acts as a slimmed down smtp
server (just sends from the local machine)? I currently use a smtp
server for sending email reports from machines, but as machines travel
outside of our lan, the smtp server refuses to relay their messages. So,
I thought it would be better if each machine had its own little mail
sender this way, it could continue reporting no matter where it was located.
It is not good to send mail from anywhere because direct smtp from
arbitrary IPs are often considered spamish. Consider setting up
secure smtp server which will receive authenticated mail from any
corporate client on special port.
These are all Windows machines... is there a Windows equivalent to
'stdin | mail -s "Subject" em***@email.com' that comes on most Unix
machines?


Sincerely yours, Roman Suzi
--
rn*@onego.ru =\= My AI powered by GNU/Linux RedHat 7.3
Jul 18 '05 #2

P: n/a
On Fri, 8 Oct 2004, Brad Tilley wrote:

Anyone know of a small Python script that acts as a slimmed down smtp
server (just sends from the local machine)? I currently use a smtp
server for sending email reports from machines, but as machines travel
outside of our lan, the smtp server refuses to relay their messages.
OK, so the clients are sending email to addresses that are not local to
your lan's server (otherwise there would be no relaying attempt)

Have you considered turning on authentication on the lan server, you can
then allow relaying only from an authenticated "client".
I thought it would be better if each machine had its own little mail
sender this way, it could continue reporting no matter where it was

located.

Sending directly from the client to the recipient address's server is
valid, doesn't need authentication, and relatively simple to do using
smtplib.py . However, nowadays this may be problematic because of
increasing anti-spam measures that *might* cause the email to be refused on
a variety of criteria (IP address (RBL) , IP address reverse lookup,
possibly SPF, etc etc ).

import smtplib
try:
s = smtplib.SMTP(outgoing-server)
failed = s.sendmail(out_from, to_list , msg)
except smtplib.SMTPRecipientsRefused, x :
do something # for recip in x.recipients: info = x.recipients[recip]
except smtplib.SMTPDataError, x:
do something # x[0], x[1]
except smtplib.SMTPSenderRefused, x :
do something # x.sender, x.smtp_code, x.smtp_error
except:
do something

(failed contains a list of failed recipients if *some* but not all failed,
if all failed then use
except smtplib.SMTPRecipientsRefused, x :)

Alternatively there are some free mail SPs out there that provide
authenticated outgoing servers that you could use if you can't turn on
authentication on your lan server.
Jul 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.