mail sending using telnet in python

P

praba kar

Dear All,
Normally we can send mail using
telnet in linux. In the following way
[~user]telnet Ipaddress 25
mail from: (e-mail address removed)
250 o.k(response of from commandline)
rcpt to: (e-mail address removed)
250 o.k(response of from commandline)
data
354 go ahead(response of from commandline)
Hello world(message to send)
..
250 ok 1120805818 qp 1463

Is it possible to run same thing same manner
in python? If possible kindly help me with
specimen code. Actually I gone through
telnetlib module documentation but I cann't
get solution for it.

regards
prabahar







__________________________________________________________
Free antispam, antivirus and 1GB to save all your messages
Only in Yahoo! Mail: http://in.mail.yahoo.com
 
M

Max M

praba said:
Dear All,
Normally we can send mail using
telnet in linux. In the following way
Is it possible to run same thing same manner
in python? If possible kindly help me with
specimen code. Actually I gone through
telnetlib module documentation but I cann't
get solution for it.

Why not just use the smtp module? It's a tad easier.

--

hilsen/regards Max M, Denmark

http://www.mxm.dk/
IT's Mad Science
 
J

Jorgen Grahn

Dear All,
Normally we can send mail using
telnet in linux. In the following way
[~user]telnet Ipaddress 25
mail from: (e-mail address removed)
250 o.k(response of from commandline)
....

That is sometimes a very useful trick, but it doesn't always work. SMTP
requires CR-LF line endings, but your example only generates LF. Most mail
servers accept that, but they are not required to, and some don't (qmail?).
Is it possible to run same thing same manner
in python? If possible kindly help me with
specimen code. Actually I gone through
telnetlib module documentation but I cann't
get solution for it.

When you use the telnet command to do it, you're simply abusing telnet to
get a command-line interface to a TCP socket -- it's really only intended to
talk to a telnet server. . If the 'netcat' utility was more widespread,
everyone would have used it instead.

When you use Python, it doesn't make sense to go through telnetlib. Use
module socket instead.

Or, simply use module smtplib, which also comes with example code (in Python
2.3, at least).

Have fun,
Jorgen
 
P

Piet van Oostrum

praba kar said:
PK> Normally we can send mail using
PK> telnet in linux. In the following way
PK> [~user]telnet Ipaddress 25

In fact you are using SMTP through the telnet program. So in Python use
the smtplib module.
 
S

Sybren Stuvel

praba kar enlightened us with:
Is there any php equivalent move_uploaded_file($source_path,
"$upload_dir/$name"); function in python to upload a file to server?

move_uploaded_file does NOT upload a file to a server.
Kindly give me answer.

Kindly ask answerable question.

Sybren
 

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
473,985
Messages
2,570,199
Members
46,766
Latest member
rignpype

Latest Threads

Top