# # Wesleyan University # COMP 360, Section 1, Fall 2016 # V. Manfredi # # Sending email using openssl # #========================================================= # Connect to mail server. E.g., #========================================================= # Wesleyan mail server: openssl s_client -crlf -connect exchange2010.wesleyan.edu:465 # Gmail mail server openssl s_client -crlf -connect smtp.gmail.com:465 # From the server you should see something like 220 exchcas3.wesad.wesleyan.edu Microsoft ESMTP MAIL Service ready at Wed, 21 Sep 2016 12:19:27 -0400 OR 220 smtp.gmail.com ESMTP 44sm19281105qtt.5 - gsmtp #========================================================= # Say hello #========================================================= # Type at hanging prompt a HELO or Extended HELO (EHLO) # including your sending domain (although not clear it matters # what you type here), and I've just been typing my email username EHLO vumanfredi # From the server you should see something like the following in response 250-exchcas3.wesad.wesleyan.edu Hello [129.133.7.96] OR 250-smtp.gmail.com at your service, [129.133.188.219] #========================================================= # Authentication time #========================================================= # First convert your username and password to binary. Type # these commands in a separate terminal, using your username # and replacing password with your password. You'll get # back some base64 encoded strings that you will enter at the # hanging SMTP prompt. If you're using gmail (and 2-factor # authentication you may need to generate an app password, # see the following website for more details https://support.google.com/accounts/answer/185833?p=InvalidSecondFactor&visit_id=1-636100677231869734-2558592835&rd=1 perl -MMIME::Base64 -e 'print encode_base64("username\@wesleyan.edu")' perl -MMIME::Base64 -e 'print encode_base64("password")' # Enter those base64 encoded strings at the SMTP prompt # To do so, first type auth login # You should see in response, something like 334 VXNlcm5hbWU6 # Paste your username string and press enter. You should see in response # something like, 334 UGFzc3dvcmQ6 # Now paste your password string. You should see in response: 250 2.1.5 Recipient OK #========================================================= # Generate the email #========================================================= # Specify the sender by typing the following at prompt. # Note the use of brackets: < > MAIL FROM: # You should see in response 250 2.1.0 Sender OK # Specify the receiver by typing the following at prompt. # Note that "rcpt to:" is in lower case. The "r" is really # all that needs to be lower case. Upper case R tells openssl # you want to renegotiate, which you do not want to do. So # this is just a hack for dealing with openssl rcpt to: # You should see in response 250 2.1.5 Recipient OK # Now generate and send the data. Type at the prompt DATA # You should see in response 354 Start mail input; end with . OR 354 Go ahead qkg.23 - gsmtp # Enter the data to send. E.g., From: me To: you Subject: test . # You should see in response, something like 250 2.6.0 [InternalId=37375198] Queued mail for delivery OR 250 2.0.0 OK qkg.23 - gsmtp #========================================================= # Done. Close connection #========================================================= QUIT