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

    Join Date
    Jun 2010
    Posts
    1
    Rep Power
    0

    Some conceptual questions about how mail works


    I have some conceptual questions about how mail works. I'm a web programmer w/ limited sysadmin experience. I've always taken for granted that the server I'm programming on is able to send out email. Typically, I use PHP's mail() function and it just works. Now I'm working on a server (Windows Server) that is not running an SMTP server, so I need to figure out how to send out mail.

    Let's say my server is foo.bar.org and I work for bar.org, which has many servers. I want the webserver on foo to be able to send out email. I think that one way to do this is to get an email address from bar.org (which has an SMTP server running), and set up the webserver on foo to connect to that SMTP server to send out email. Will that work?

    I think that another way to make this work is to run an SMTP server on foo, and have the webserver connect to it (i.e., on localhost). But then how does the SMTP server know which machine to connect to, to send and receive emails? Does it connect directly to the SMTP server named in the email's "To:" field? In other words, if the email is address to "bill@microsoft.com", will my SMTP server connect directly to port 25 on microsoft.com?

    Thanks.
  2. #2
  3. No Profile Picture
    Lost in code
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 2004
    Posts
    8,317
    Rep Power
    7170
    set up the webserver on foo to connect to that SMTP server to send out email. Will that work?
    Yes

    Does it connect directly to the SMTP server named in the email's "To:" field?
    Sort of. It actually looks up the DNS records for the domains in the to field, identifies the MX records and then contacts one of the SMTP servers running on the addresses specified in the MX records.
    PHP FAQ

    Originally Posted by Spad
    Ah USB, the only rectangular connector where you have to make 3 attempts before you get it the right way around
  4. #3
  5. No Profile Picture
    Grumpier old Moderator
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jun 2003
    Posts
    14,440
    Rep Power
    4539
    If your windows server has IIS, most versions of IIS have an optional built-in SMTP server. If you have another mail server on the same LAN usually that works fine.

    Using external smtp servers from server-side code can be problematic. The SMTP port is often blocked by admins or ISP's. The remote SMTP server may think you're a spammer and reject connections from your server.

    But you can use external smtp servers, I use my ISP smtp server with local web code.
    ======
    Doug G
    ======
    Bartender to Rene Descartes "have another beer?" Descartes: "I think not" and he vanished.
    --Alfred Bester

IMN logo majestic logo threadwatch logo seochat tools logo