請問怎麼用socket程式寫寄信

請問各位前輩,如何用socket、port(25)

寄信給xxx@gmail.com

當我建立連線是要跟google做連線還是??

可以告訴我流程或大概?給指示我一個方便謝謝

1 Answer

Rating
  • Chen
    Lv 6
    9 years ago
    Favorite Answer

    very simple protocol SMTP protocol see RFC 821 document, RFC is free

    1. client (user) connect email server ( 25 port) by TCP

    client rival email server

    connect

    ------------------------------->

    <------------------------------

    server greet( 220) OK

    HELLO your email server

    ---------------------------->

    send_OK ( 220)

    <-----------------------------

    MAIL FROM: your email\n

    ------------------------------>

    <----------------------------

    send_OK(250)

    RCPT TO: send to whom1

    -------------------->

    <--------------------

    send_OK(250 or 251)

    RCPT TO: send to whom2

    -------------------->

    <--------------------

    send_OK(250 or 251)

    .

    .

    no Bcc or cc

    DATA ( data mode)

    ------------------------->

    <--------------------------

    send_OK

    send MIME data

    . (leave data mode)

    ---------------------->

    <--------------------

    OK

    close socket

    2. above statement is experience of my coding program.

Still have questions? Get your answers by asking now.