#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25

    Emailing with python


    Is there a mdoule that lets you email something without having to use a smtp server? I have done some reaseach but i havn't fond anything that worked without an smtp server

    thanks
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    The Win32 extensions allow you to use COM to automate Outlook to send an email through Exchange using MAPI...

    Being pedantic, as I like to be, yes you can, but mostly what you're asking doesn't make sense. It would be like "how can I serve a web page without a web server".
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    This is going to be on linux and what i am asking is a way for me to send an email without having to specify an smtp server. Like with php you can have it send emails without having to specify an smtp server. i was wondering if there was a way to do it with python.
  6. #4
  7. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Actually, if you want to send an email though PHP it has to be preconfigured: this basically involves providing a default mail-server for it to use (,localhost if your linux box is running a local mail-server). This configuration is usually done by the hosting company, which is why you get the effect of PHP being able to send emails internally .

    Anyway, I wrote a function a while back for an article here on Devshed that you might be interested in: http://www.devshed.com/c/a/Python/Python-on-the-Web/3/

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2004
    Posts
    461
    Rep Power
    25
    I have never used a hosting company actually. But I didnt' realize that, i have just always spified my own mail server. I knew html had a way. I will chekc out that function thank you
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Regensburg, Germany
    Posts
    147
    Rep Power
    16
    On linux, you can use the linux "mail" (stupid trick, but it works):

    Code:
    import os, tempfile
    
    tf = tempfile.mktemp()
    open(tf, "w").write(mail_body)
    my_subject = "My Subject"
    receiver = "someone@somewhere.com"
    cmd = 'cat %s|mail -s "%s" %s' % (tf, my_subject, receiver)
    os.system(cmd)
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2004
    Posts
    40
    Rep Power
    10
    how about if i want to send mail with attachment(s) ??
    i was try to do so with MIMEMultipart..
    it's looks nice when i send the 1st mail (1st time i call the code).
    but the problem comes when i call it for 2nd time where it will automatically duplicated the 1st mail.
    Eg: 1st mail
    msg + att1 + att2
    Eg: 2nd mail
    msg + att1 + att2 + {msg + att1 + att2 (from 1st mail)}

    any idea?
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    Regensburg, Germany
    Posts
    147
    Rep Power
    16
    Do you create a new MIMEMultipart object for every message you send? If not, this may be the problem.

IMN logo majestic logo threadwatch logo seochat tools logo