Hi Payal,
I see you're connecting to an smtp server Any particular reason yoou
can't use smtplib?
http://www.python.org/doc/current/lib/module-smtplib.html
Here's a sample script using smtplib to send an email -
import smtplib
ip = "127.0.0.1"
txt = "This is an email message"
c = smtplib.SMTP(ip)
c.sendmail("[EMAIL PROTECTED]", "[EMAIL PROTECTED]", txt)
c.close()
Although it's better to use an email.Message object for this -
http://www.python.org/doc/current/lib/module-email.Message.html
Here's the same script with an email.Message
import smtplib
import email.Message as Mg
ip = "127.0.0.1"
msg = Mg.Message()
msg["To"] = "[EMAIL PROTECTED]
msg["From"] = "[EMAIL PROTECTED]"
msg["Subject"] = "Test message"
msg["Reply-To"] = "[EMAIL PROTECTED]"
txt = "This is an email message"
msg.set_payload(txt)
c = smtplib.SMTP(ip)
c.sendmail("[EMAIL PROTECTED]", "[EMAIL PROTECTED]", msg.as_string())
c.close()
Regards,
Liam Clarke
On 4/25/06, Payal Rathod <[EMAIL PROTECTED]> wrote:
> Hi,
> I need to automate connection to a IP like this. The IP (or domain name)
> is taken from command line or from user (whichever is easier for me to
> code). It should emulate,
>
> telnet 127.0.0.1 25
>
> mail from: <[email protected]>
> 250 ok
> rcpt to: <[EMAIL PROTECTED]>
> 250 ok
> quit
>
> Can Python do this for me? How do I start?
>
> With warm regards,
> -Payal
>
> _______________________________________________
> Tutor maillist - [email protected]
> http://mail.python.org/mailman/listinfo/tutor
>
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor