Simple Python script as SMTP server for outgoing e-mails?

G

Gilles

Hello

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

Thank you.
 
C

Chris Angelico

Hello

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

Rather than write something from scratch, I'd look at deploying
something out-of-the-box - Postfix, for instance - which you will be
able to configure much faster than writing your own. And then you
could have it either send via your ISP or send directly to the
receiving MTA, without much extra effort.

ChrisA
 
G

Gilles

Rather than write something from scratch, I'd look at deploying
something out-of-the-box - Postfix, for instance - which you will be
able to configure much faster than writing your own. And then you
could have it either send via your ISP or send directly to the
receiving MTA, without much extra effort.

Thank you but precisely, I was looking for a "ready-to-use solution in
Python" so that I wouldn't have to write it myself.

Also, I don't need a full-fledged SMTP server, just a tiny script that
will let me send the occasional e-mails from my e-mail client that my
ISP wrongly considers as SPAM.

So, does someone know of a good, SMTP server just to send e-mails?

Thank you.
 
D

Dennis Lee Bieber

Hello

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Many ISPs now block "pass through" SMTP -- especially original port 25
SMTP; only "their" server is permitted to connect to outside hosts.

If all your destinations are using TLS with alternate ports, you might
be okay, but if the mail is being sent over port 25, it won't go anywhere.

WinXP Pro supposedly contains an SMTP server as part of the "Internet
Information Services" (IIS6) suite (optional component activated via
control panel). Win7 Pro seems to have removed that (SMTP) component from
IIS7.
 
M

Michael Torrie

So, does someone know of a good, SMTP server just to send e-mails?

What you're looking for is not an SMTP server but a Mail Transfer Agent,
called an MTA.

Pretty much all distros ship with an MTA by default, even if the SMTP
server part of it isn't installed or running. And often the MTA is, for
compatibility reasons, /usr/sbin/sendmail.

http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

I'm sure there are MTA's implemented in python. Now that you know what
they are called (not SMTP servers!) you can search for them.

Dennis is correct, though, that most ISPs do block outbound port 25
connections for security and spam reasons, and require you to use their
SMTP server, which precludes the use of the local MTA.
 
G

Gilles

What you're looking for is not an SMTP server but a Mail Transfer Agent,
called an MTA.

Pretty much all distros ship with an MTA by default, even if the SMTP
server part of it isn't installed or running. And often the MTA is, for
compatibility reasons, /usr/sbin/sendmail.

http://stackoverflow.com/questions/73781/sending-mail-via-sendmail-from-python

I'm sure there are MTA's implemented in python. Now that you know what
they are called (not SMTP servers!) you can search for them.

Dennis is correct, though, that most ISPs do block outbound port 25
connections for security and spam reasons, and require you to use their
SMTP server, which precludes the use of the local MTA.

Thanks for the infos. Ideally, I was looking for a simple Windows app
as MTA, but a Python script is OK.

I'm not sure my ISP blocks outbound port 25 connections. I'll
experiment with a small Linux box.

I wist they would use a smarter SPAM filter that wouldn't flag
perfectly legit-looking outgoing e-mails.
 
I

Ivan Shmakov

[Cross-posting to news:comp.mail.misc.]
What you're looking for is not an SMTP server but a Mail Transfer
Agent, called an MTA.
[...]
Dennis is correct, though, that most ISPs do block outbound port 25
connections for security and spam reasons, and require you to use
their SMTP server, which precludes the use of the local MTA.
I'm not sure my ISP blocks outbound port 25 connections. I'll
experiment with a small Linux box.

There's yet another issue: certain email "operators" may block
/inbound/ port 25 connections from ISP "customer" networks.
I wist they would use a smarter SPAM filter that wouldn't flag
perfectly legit-looking outgoing e-mails.

FWIW, it may also be possible to use an email service (such as
Google Mail) provided by a third-party.
 
G

Grant Edwards

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server. All I'd need is to change the SMTP
address in my e-mail client, and off they go. No need for anything
else like user authentication or SPAM control.

Unless you've got a static IP address, a domain name, and a valid MX
record that will match up when they do a reverse DNS lookup, it's
pretty unlikely that you're going to have much luck running an SMTP
server. Most other SMTP servers are probably going to ignore or
reject your attempts to transfer mail from your own SMTP server.
Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

I'd recommend postfix or exim if I was going to try to do it, but I
think they're Unix-only.
 
M

Michael Torrie

Thanks for the infos. Ideally, I was looking for a simple Windows app
as MTA, but a Python script is OK.

The Sendmail MTA has been ported to many platforms including windows.
But...
I'm not sure my ISP blocks outbound port 25 connections. I'll
experiment with a small Linux box.

Having spent a long time managing e-mail servers, everything Ivan said
in his reply is true as well. I had forgotten a lot of that since I
haven't been running my own mail server (MTA or server part) in a while.
I've sold my soul to Google for e-mail now with Google Apps for my
domain.
I wist they would use a smarter SPAM filter that wouldn't flag
perfectly legit-looking outgoing e-mails.

But then how would it know that legit-looking e-mails aren't in fact
SPAM? E-mail is starting to be an almost intractable problem. No
wonder the younger generations are just abandoning it entirely in favor
of centralized, cathedral-style messaging systems such as facebook.
 
G

Gilles

The Sendmail MTA has been ported to many platforms including windows.
But...

Thanks for the tip. Since I couldn't find a good, basic, native
Windows app, I was indeed about to look at eg. Exim + Cygwin, and
resort to a Linux appliance if none footed the bill.
Having spent a long time managing e-mail servers, everything Ivan said
in his reply is true as well. I had forgotten a lot of that since I
haven't been running my own mail server (MTA or server part) in a while.

Indeed, I had forgotten about some MTAs refusing incoming e-mails from
other ISP's customer hosts. I'll experiment.
But then how would it know that legit-looking e-mails aren't in fact
SPAM?

It generally does a good job, but every once in a while, some
perfectly good e-mail I'm sending is flagged as SPAM. To keep all my
e-mails in the same client, I'd rather use a local MTA than sending
the e-mail from Gmail.

Thank you.
 
G

Gilles

Unless you've got a static IP address, a domain name, and a valid MX
record that will match up when they do a reverse DNS lookup, it's
pretty unlikely that you're going to have much luck running an SMTP
server. Most other SMTP servers are probably going to ignore or
reject your attempts to transfer mail from your own SMTP server.

I had forgotten about this. I'll give a try, and see how it goes.
I'd recommend postfix or exim if I was going to try to do it, but I
think they're Unix-only.

Thanks for the tip. Looks like Exim is available on Windows through
Cygwin
http://blogostuffivelearnt.blogspot.fr/2012/07/smtp-mail-server-with-windows.html
 
G

Gilles

Unless you've got a static IP address, a domain name, and a valid MX
record that will match up when they do a reverse DNS lookup, it's
pretty unlikely that you're going to have much luck running an SMTP
server. Most other SMTP servers are probably going to ignore or
reject your attempts to transfer mail from your own SMTP server.

Incidently, how do ISP MTAs find whether the remote MTA is legit or
running on some regular user's computer?

1. Query Reverse DNS for IP
2. Find domain
3. Query DNS for MX
4. ?
 
C

Chris Angelico

Indeed, I had forgotten about some MTAs refusing incoming e-mails from
other ISP's customer hosts. I'll experiment.

One thing to check when you change how you send mail is your SPF
record. I run the mail server for kepl.com.au and have set its SPF to:

"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all"

If your SPF is as strict as mine (and if it's not, please make it so,
for the sake of the rest of the world!), you'll want to check it
before you start sending mail directly from your own computer.
Otherwise your mail _will_ be rejected as spam.

ChrisA
 
G

Gilles

One thing to check when you change how you send mail is your SPF
record. I run the mail server for kepl.com.au and have set its SPF to:

"v=spf1 ip4:122.107.147.136 ip4:203.214.67.43 ip4:192.168.0.0/16 -all"

If your SPF is as strict as mine (and if it's not, please make it so,
for the sake of the rest of the world!), you'll want to check it
before you start sending mail directly from your own computer.
Otherwise your mail _will_ be rejected as spam.

Thanks for the tip. I didn't know about SPF
http://en.wikipedia.org/wiki/Sender_Policy_Framework
 
C

Chris Angelico

Thanks for the tip. I didn't know about SPF
http://en.wikipedia.org/wiki/Sender_Policy_Framework

It's a great way of detecting legit vs forged mail. If anyone tries to
send mail purporting to be from (e-mail address removed) and the receiving
mail server is checking SPF records, it'll be rejected after one cheap
DNS lookup. It's a simple and cacheable way to ask the owning server,
"Is this guy allowed to send mail for you?". (The 192.168 block in my
SPF record above is permitted to allow some intranet conveniences;
omit it unless you need it.)

ChrisA
 
M

Michael Torrie

It's a great way of detecting legit vs forged mail. If anyone tries to
send mail purporting to be from (e-mail address removed) and the receiving
mail server is checking SPF records, it'll be rejected after one cheap
DNS lookup. It's a simple and cacheable way to ask the owning server,
"Is this guy allowed to send mail for you?". (The 192.168 block in my
SPF record above is permitted to allow some intranet conveniences;
omit it unless you need it.)

Yes setting SPF records will help your mail be accepted by other
servers, but I disagree with your appeal to make mail server SPF
handling as strict as your server does. SPF has problems in a number of
situations which could cause legitimate mail to be rejected. In my last
job I could only use SPF as one spam factor, not as a basis for rejection.
 
G

Grant Edwards

Incidently, how do ISP MTAs find whether the remote MTA is legit or
running on some regular user's computer?

1. Query Reverse DNS for IP
2. Find domain
3. Query DNS for MX
4. ?

There are a variety of things they check. They've got lists of IP
address blocks that they know are residential DSL/cable customers, and
sometimes they'll reject mail from those regardless of what you do.

Some will compare the reverse-DNS lookup with the headers to make sure
you're being honest about things like return-path, some will compare
the IP address with the MX record for the domain they got when they
did the reverse-lookup-DNS, and they've all probably got a variety of
other secret heuristics they use to generate a "SPAM" score.

For many years I ran my own SMTP server and had it configured to
deliver mail directly to recipients. About 10 years, I had to give up
on that because so many SMTP servers were rejecting/ignoring mail I
sent. And I did have a static IP with a valid domain and MX record.

But it was a residential DSL IP address, and I suspect that was enough
to get mail rejected by some servers.
 
M

Michael Torrie

Thanks for the tip. Since I couldn't find a good, basic, native
Windows app, I was indeed about to look at eg. Exim + Cygwin, and
resort to a Linux appliance if none footed the bill.

Where did you look? Here's one I found. It's not the real sendmail
program, but it implements the interface which is all you need:

http://glob.com.au/sendmail/

I just googled for sendmail win32
 
K

Kevin Walzer

Hello

Every once in a while, my ISP's SMTP server refuses to send
perfectly legit e-mails because it considers them as SPAM.

So I'd like to install a dead-simple SMTP server on my XP computer
just to act as SMTP backup server.
All I'd need is to change the SMTP address in my e-mail client, and
off they go. No need for anything else like user authentication or
SPAM control.

Is there a no-brainer, ready-to-use solution in Python that I could
use for this?

Thank you.

http://www.hmailserver.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top