How to lunch webpage without using SMTP server?

N

Nancy

Hi, Guys,
Is there any other way to use python or mod_python writing a web page?
I mean, not use "form.py/email", no SMTP server.
<form action="form.py/email" method="POST"> ...

Thanks a lot.

Nancy W
 
G

Grant Edwards

I think she's trying to say: Is there away to send an email
from a web page without having a SMTP server.

I'm afraid I don't quite know what it means to "send an e-mail
from a web page."

Hmm, I don't see how you could use that to send an e-mail.
I believe a SMTP server (of sometype) is required somewhere.
That said maybe you can use

If what she's trying to do is send an e-mail from a Python
program (running as a CGI program or ASP handler, or Zope
something-or-other perhaps?), then what she needs is an SMTP
client module like the one implimented by
http://docs.python.org/lib/module-smtplib.html.

To use such an SMTP client, yes, you have to have an SMTP
server to which you can send the e-mail. There's not really
any way around that. SMTP is how e-mail is transferred on the
Internet, and to send an mail you need to connect to an SMTP
server.

You can't send mail with an SMTP server. The direction of
e-mail transfer in SMTP is client --> server. [Unless there
are SMTP extensions that allow bi-directional mail transfers?
I've never seen one in use...]
 
D

Doug Holton

Nancy said:
Hi, Guys,
Is there any other way to use python or mod_python writing a web page?
I mean, not use "form.py/email", no SMTP server.
<form action="form.py/email" method="POST"> ...

So what you want is to be able to send email from a python script
running on your Windows computer, but you don't have access to an SMTP
server.
So you need to run your own SMTP server on your Windows computer. If
you want to do this for a real application, you should get a good SMTP
server (there are some free ones like blat or xmail).

But here are steps to run a crude SMTP server implemented in Python.

Download the two python files from http://www.hare.demon.co.uk/pysmtp.html

Download the zip file for the PyDNS module from
http://pydns.sourceforge.net/

You need to open a command window and install PyDNS. Run "python
setup.py install"

After you have installed PyDNS, then before you can run the SMTP server
you need to find out what DNS server your internet connection is using.
Go to control panel -> network. Click on your network connection, hit
the support tab and then click details to see what DNS servers you are
using. Copy one of them.

Then you can start the SMTP server in a command window. Run "pyspy.py
25 <dns server here>".

If it is running, then run this test script and see if you get the email:

import smtplib

SMTP_SERVER = "localhost"
FROMEMAIL = "(e-mail address removed)"
TOEMAIL = "(e-mail address removed)"

msg = """From: %s
Subject: test email
To: %s

This is a test message to %s
""" % (FROMEMAIL, TOEMAIL, TOEMAIL)

conn = smtplib.SMTP(SMTP_SERVER)
conn.sendmail(FROMEMAIL, [TOEMAIL], msg)
conn.quit()
 
D

Doug Holton

You need to open a command window and install PyDNS. Run "python
setup.py install"

And to help make using the command window easier, I'd recommend you
install the CmdHere Windows XP program from here:
http://www.microsoft.com/windowsxp/downloads/powertoys/xppowertoys.mspx

That way, after you unzip pydns into a folder, you can just right-click
on the folder and choose "Open Command Window Here" and run the command.

If "python setup.py install" gives an error that python cannot be found,
try the full path: "\Python23\python.exe setup.py install"
 
C

Cameron Laird

Nancy wrote: .
.
.
So what you want is to be able to send email from a python script
running on your Windows computer, but you don't have access to an SMTP
server.
So you need to run your own SMTP server on your Windows computer. If
.
.
.
No, you don't. If anything, as Grant Edwards points out elsewhere
in this thread you need SMTP *client* code--which is easy enough in
Python.

I do this--emitting e-mail from my applications by direct connection
to the e-mail server of addressee--often. It's modestly hazardous,
in that one either makes the cheerful assumption that the server
will be accessible, OR one starts to build the re-try queues that
head one down the slippery slope to re-creation of sendmail.

There are still other possibilities, by the way; one can, for example,
ahve the Python application connect by way of SMTP to a server one
controls that happens not to be on the host of the Python application.

I summarize: yes, it's almost certainly possible, in some sense; you'll
want to specify your situation more precisely before starting to write
code.
 
B

Byron

Hi Nancy,

In order to be able to send an e-mail, you need to use either an SMTP
server or have the know-how skill to be able to route the message
yourself. I would HIGHLY recommend that you use an SMTP server.

Here's a code snipplet that you might find helpful:

def sendmessage(toaddr, fromaddr, message):
server = smtplib.SMTP('mail.some-server.com')
server.login("(e-mail address removed)", "mySecretPassword")
server.sendmail(fromaddr, toaddr, message)
server.quit()

You can use this function by doing the following:

sendmessage("(e-mail address removed)", "(e-mail address removed)", "Let's
have lunch someday via smtp! <grin>")

Hope this helps,

Byron
 
D

Doug Holton

Cameron said:
.
.
.
No, you don't. If anything, as Grant Edwards points out elsewhere
in this thread you need SMTP *client* code--which is easy enough in
Python.

No, she does need to run her own SMTP server since she doesn't have
access to an existing one. You don't know the history of this thread.
 
D

Doug Holton

Byron said:
Hi Nancy,

In order to be able to send an e-mail, you need to use either an SMTP
server or have the know-how skill to be able to route the message
yourself. I would HIGHLY recommend that you use an SMTP server.

Here's a code snipplet that you might find helpful:

def sendmessage(toaddr, fromaddr, message):
server = smtplib.SMTP('mail.some-server.com')
server.login("(e-mail address removed)", "mySecretPassword")
server.sendmail(fromaddr, toaddr, message)
server.quit()

Again, we've been through all this before. She doesn't have access to
an SMTP server, apparently. She only uses hotmail.
That is why I answered her with instructions on how to run her own SMTP
server just for testing purposes.
 
B

Byron

Hi Doug,

I agreed with your response. In my reply, I mentioned that she would
have two options, which are to either *get* SMTP access -- or -- to find
some program, plugin, etc that would act as a SMTP server for her.

If she is able to obtain smtp access, then the code I provided below
could be used / modified for it.

Byron
 
G

Grant Edwards

In order to be able to send an e-mail, you need to use either
an SMTP server or have the know-how skill to be able to route
the message yourself.

Route it to where if not to an SNMP server?
I would HIGHLY recommend that you use an SMTP server.

I simply don't see how you can send mail without using an SMTP
server.
 
G

Grant Edwards

I agreed with your response. In my reply, I mentioned that
she would have two options, which are to either *get* SMTP
access -- or -- to find some program, plugin, etc that would
act as a SMTP server for her.

And if she doesn't have access to an SMTP server that will
accept e-mail from her system, what is that local SMTP server
going to do with the e-mail?

True, she can technically "send" e-mail by connecting to an
isolated, local SMTP server, but the mail won't be delivered to
anybody who isn't on her local server. That's OK if she only
wants to send local e-mail.
If she is able to obtain smtp access, then the code I provided below
could be used / modified for it.

If that's true, then she can't send e-mail to non-local
addresses -- regardless of whether she's running a local SMTP
server or not.

If it's strictly for testing purposes, and the mail doesn't
need to get delivered, then running a local SMTP server is a
good solution. I must have missed that it was for "just
testing".
 
B

Byron

Hi Grant,

Yes, I agree with you that it would have to be an SMTP server.

What I was referring to is that I found a python script (in the past)
that had the ability to act like a "limited" SMTP server and send e-mail
messages on the net.

Byron
 
M

Matthew Scott

Grant said:
I'm afraid I don't quite know what it means to "send an e-mail
from a web page."

If the web page has something like:
<form action="mailto:[email protected]">...</form>

You can send an email from that web page.


Quoted from http://htmlhelp.com/reference/html40/forms/form.html:

"A mailto URI (e.g., mailto:[email protected]) is also allowed as an
ACTION, but this is not supported by all browsers. Non-supporting
browsers such as Microsoft Internet Explorer 3.x typically will open a
blank e-mail message when the user submits a mailto form. Even on
supporting browsers, mailto forms are troublesome in that they fail to
provide feedback to the user after the form submission."
 
G

Grant Edwards

If the web page has something like:
<form action="mailto:[email protected]">...</form>

You can send an email from that web page.


Quoted from http://htmlhelp.com/reference/html40/forms/form.html:

"A mailto URI (e.g., mailto:[email protected]) is also allowed as an
ACTION, but this is not supported by all browsers. Non-supporting
browsers such as Microsoft Internet Explorer 3.x typically will open a
blank e-mail message when the user submits a mailto form. Even on
supporting browsers, mailto forms are troublesome in that they fail to
provide feedback to the user after the form submission."

And if the browser impliments that type of URL, it's going to
need access to an SMTP server.
 
D

David Bolen

Grant Edwards said:
And if she doesn't have access to an SMTP server that will
accept e-mail from her system, what is that local SMTP server
going to do with the e-mail?

If she's really running a local SMTP "server" (as opposed to just a
dumb forwarder of some sort), then her local server should be
interrogating DNS to locate the appropriate delivery host for the mail
as addressed, and connecting directly there. Now, if you're saying
that the final target SMTP agent/server isn't going to accept e-mail
from her system, she's stuck no matter what she does since there's
just no way for her to send mail to that target address. (Or rather,
then in that case she really does need a remote server running on a
host that hte final delivery server will accept connections from).
If that's true, then she can't send e-mail to non-local
addresses -- regardless of whether she's running a local SMTP
server or not.

She can if said local server talks to the final delivery SMTP
agents/servers. They have to be listening or the e-mail addresses
specifying their use for mail delivery won't work at all.

-- David
 
G

Grant Edwards

She can if said local server talks to the final delivery SMTP
agents/servers. They have to be listening or the e-mail addresses
specifying their use for mail delivery won't work at all.

I assumed that somebody who "doesn't have access to an SMTP"
doesn't have access to any SMTP servers. If "an SMTP server"
means "a local SMTP" or "a relaying SMTP server", then that's a
different story.
 
D

David Bolen

Grant Edwards said:
I simply don't see how you can send mail without using an SMTP
server.

If that includes the final delivery agent that is listening on an SMTP
port to provide delivery to a mailbox on the remote end, I agree. But
to the extent that such a server is being run by a separate
administrative entity, you might not include it in discussions talking
about the client machine. That SMTP server is handling the delivery
end of the mail, not the transmitting.

Typically, when I see discussions of running your own SMTP server,
it's to get the benefits that most servers implement of queueing,
handling DNS information, error bounce messages, and in general robust
management of delivery to the target. But that refers to a local SMTP
server providing such functionality and not the delivery SMTP
agent/server at the destination address. I'm guessing that's what
Bryan may have been referring to. (Run a server locally, and just
hand it messages to deliver).

But you can certainly write SMTP client code that can deliver a
message properly to anyone on the net without needing a local SMTP
server. Heck, you can do it interactively with dig/nslookup and
telnet. Just ask DNS for the MX information properly, resolve the
host(s) down to their IP addresses, and then connect to the delivery
agent there, and transmit the message. It's much easier to have a
smart local SMTP server to take care of the grunge work for you, but
it's certainly doable if you don't have one.

-- David
 

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

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,664
Latest member
RoseannBow

Latest Threads

Top