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

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10

    Help with email sending and retreiving


    how can i send and recieve emails through python. I know you use the smtplib module but what host should i plug into this if i use hotmail?:

    >>> import smtplib
    >>> s=smtplib.SMTP("localhost")
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    soo basically noone knows????
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Did you read the link? And some of the comments following it?

    "Free email services like Hotmail don't have mail servers that you can plug into just any email client. They are typically web-only services.

    Why? Because they're free. They make money by presenting advertising, or links to other sites, along with your email. If they allowed access to any other email clients, that advertising would disappear."

    They don't have them. You can't do it without stepping up to one of the extra hotmail services that costs money.

    Comments on this post

    • miryln agrees : oh ok i get it now
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by miryln
    soo basically noone knows????
    I know how to send email; receiving it depends on you having a valid account on the system though. The code is in my article here:

    http://www.devshed.com/c/a/Python/Python-on-the-Web/3/

    Google is your friend,

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

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    ##That code is too complicated I have finally figured out ##what to do here is the code:

    import smtplib
    def mail(address, subject, message, host = 'localhost'):

    msg = """\
    FROM: chachi
    SUBJECT: THiS is kinda cool

    soo anyways u change all this to ur personal preferences and u use the smtplib to sendmail to recipiants.
    """
    s = smtplib.SMTP('mail')
    s.sendmail('from@hotmail.com', 'to@hotmail.com', msg)

    s.quit()
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    with all this comes one problem, if u want to send email from other domain names you end up sending your ip address too. because of hotmails sender id The message will either be denied or sent to junk mail. ANYONE KNOW HOW TO CHANGE SENDER ID???
  14. #8
  15. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Originally Posted by miryln
    with all this comes one problem, if u want to send email from other domain names you end up sending your ip address too. because of hotmails sender id The message will either be denied or sent to junk mail. ANYONE KNOW HOW TO CHANGE SENDER ID???
    No clue, it didn't used to end up in Junk mail when I wrote the function .

    It could be being sent as a header but it seems more likely hotmail is just records the IP of any connections made to it, in which case you could try masking your IP or something similar?

    Also, what you mean by too complicated is that you don't get it right?

    It's really very simply, and explained fully on the page. The function was designed to take a number of email addresses because it makes more sense to do it that way than to send the same email to people individually.

    All you've done to make it more simple is to remove that and to put the header string into a less precise form you have no control over what line endings that are being used and that can cause some big problems from my experience .

    You don't have to have it so it can send to multiple email addresses (I linked to it so you could see how it worked) but you should leave the header construction as is because "\r\n" is required. So your script may fail on systems that use just an "\n".

    You should also read the how to ask a question thread at the top of the forum to find out how to use code tags .

    Take care,

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

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

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    yes that is what im saying. Im new to python and that is too complicated for me to understand. Could you tell me te function to mask your i.p. address. thankyou for the article is there anyway you could explain it better or should i just read it more?
  18. #10
  19. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2006
    Location
    Russia, Siberia, Kemerovo
    Posts
    1
    Rep Power
    0
    And what about retreiving NEW messages from POP3 server? How to do this? I can't see any function in poplib which checks for "seen" flag of a message.
    Any suggestions?

    Thanks.
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    Originally Posted by kornerr
    And what about retreiving NEW messages from POP3 server? How to do this? I can't see any function in poplib which checks for "seen" flag of a message.
    Any suggestions?
    You will need to track that yourself, AFAIK.

    Probably easiest done with the UIDL command - it returns a unique identifier for each message on the server.

    Track the unique identifiers, and only retrieve messages you haven't seen before.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Nov 2003
    Posts
    624
    Rep Power
    34
    with all this comes one problem, if u want to send email from other domain names you end up sending your ip address too.
    If you make a TCP/IP connection to a remote computer, it will always get your IP address (so it can send stuff back to you, such "packet received" acknowledgements).

    There is no way to usefully mask your IP address and have a full connection to another machine.

    The only option is to go through a proxy - but the proxy will get your IP address - and if you have an SMTP proxy and send email through it, it will put your IP address in the email itself as the source of the email.

    because of hotmails sender id The message will either be denied or sent to junk mail. ANYONE KNOW HOW TO CHANGE SENDER ID???
    The only sender ID that I know of that relates to what you are asking is SPF (Sender Policy Framework)

    When you try to send mail, the server at the other end goes through the process:

    a) This remote IP Address is trying to send email from someone@devshed.com
    b) I'll just check devshed.com and look for SPF records to see which computers are allowed to send email from @devshed.com addresses.
    c) I will allow this email/mark this email as spam based on the results of the check.

    If you are trying to send from you@hotmail.com, then any sensible receiving server will check, and find that your IP isn't allowed to send email claiming to be from a hotmail account.

    And, there's nothing you can do about it short of registering your own domain.

    Comments on this post

    • miryln agrees : good explanation
    • netytan agrees : Very nice
    Last edited by sfb; March 5th, 2006 at 06:01 PM.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2004
    Location
    california
    Posts
    53
    Rep Power
    10
    soo I am starting to understand this, but is there anyway to succesfully change your ip address or at least send the message from another ip?

IMN logo majestic logo threadwatch logo seochat tools logo