Re: How to send E-mail without an external SMTP server ?





On Oct 16, 12:31 am, "fdu.xia...@xxxxxxxxx" <fdu.xia...@xxxxxxxxx>
wrote:
Rob Wolfe wrote:
fdu.xia...@xxxxxxxxx wrote:

Hi,

I just want to send a very simple email from within python.

I think the standard module of smtpd in python can do this, but I
haven't found documents about how to use it after googleing. Are there
any examples of using smtpd ? I'm not an expert,so I need some examples
to learn how to use it.

See standard documentation:

http://docs.python.org/lib/SMTP-example.html

HTH,
RobI have read the example and copied the code and save as send.py, then I
run it. Here is the output:
$ python send.py
From: fdu.xia...@xxxxxxxxx
To: fdu.xia...@xxxxxxxxx
Enter message, end with ^D (Unix) or ^Z (Windows):
just a test from localhost
Message length is 82
send: 'ehlo [202.127.19.74]\r\n'
reply: '250-WebMail\r\n'
reply: '250 AUTH plain\r\n'
reply: retcode (250); Msg: WebMail
AUTH plain
send: 'mail FROM:<fdu.xia...@xxxxxxxxx>\r\n'
reply: '502 negative vibes\r\n'
reply: retcode (502); Msg: negative vibes
send: 'rset\r\n'
reply: '502 negative vibes\r\n'
reply: retcode (502); Msg: negative vibes
Traceback (most recent call last):
File "send.py", line 26, in ?
server.sendmail(fromaddr, toaddrs, msg)
File "/usr/lib/python2.4/smtplib.py", line 680, in sendmail
raise SMTPSenderRefused(code, resp, from_addr)
smtplib.SMTPSenderRefused: (502, 'negative vibes', 'fdu.xia...@xxxxxxxxx')

Do I have to setup a smtp server on my localhost ?

You need to use login method
<http://docs.python.org/lib/SMTP-objects.html>. And by the way, the
subject of your message is very confusing, you are posting log where
you're sending email using external server.

.



Relevant Pages

  • Re: This mail sending code snippet does not work
    ... I also tested to use localhost using system.web.mail instead of the new ... I get an exception: the transport could not connect to the host when using ... There seems to be something wrong with the localhost smtp server but I can't ... I was working the local machine where the app was residing via Radmin ...
    (microsoft.public.dotnet.languages.vb)
  • RE: VB 2003, 0x80040213
    ... You will need an SMTP server you can relay through. ... server or smartrelay on them, and <localhost> will not find your ISP, since ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Sending mail from current user in Python
    ... so I'd rather stick with the standard smtplib if I can. ... >> smtplib needs an SMTP server to connect to. ... For unix systems, this is ... > I'd be very surprised if the typical SMTP server is localhost ...
    (comp.lang.python)
  • Re: sending email
    ... Are you running an SMTP server locally (on localhost)? ... MAIL FROM:anyone@domain.com (put brackets around the email addresses, ... If you do not get this email assuming you put your email address in the RCPT ...
    (microsoft.public.dotnet.framework.aspnet)
  • connecting to localhost while off line
    ... I cannot get access to my localhost when I am off line. ... Googleing ... you have to amend /etc/hosts which I have done (my system name is ... dev-system) but this has still not resolved my problem. ...
    (Ubuntu)