Path: csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail From: jt@toerring.de (Jens Thoms Toerring) Newsgroups: comp.lang.c++ Subject: Re: send email and socket programming Date: 14 Feb 2016 21:20:37 GMT Organization: Freie Universitaet Berlin Lines: 62 Message-ID: References: X-Trace: news.uni-berlin.de JSgsJz84qJ+076qNertAawGdSZ9JT9wZ0xNjQFZh3dow9N X-Orig-Path: not-for-mail User-Agent: tin/2.1.1-20120623 ("Mulindry") (UNIX) (Linux/3.2.0-4-amd64 (x86_64)) Xref: csiph.com comp.lang.c++:40921 alexo wrote: > I've written for UNIX a little program [FLTK] that needs to send an > order through e-mail. > I'm absolutely new to socket programming so you are my first attempt. > In a couple of tutorials I've built a pair of toy client/server programs > that showed me how to use sockets. It seems not so hard to program them, > but I need some help and infos. > My program is intended to be a stand alone program with a send button. > When the user hits the send button I'd like it (the program) sends an > email to my email address with the order message in it. > I know that SMTP port is 25, but I don't know how to configure the > aspects required. > Could you please guide me through that, or could you link me to a clear > intro of the subject? This rather likely won't work, even if you get everything right. There are the following issues: a) You need to figure out the mail server for the address you want to send the email to. Many machines don't accept connections on port 25 (or there's a firewall that prevents accessing the port from the outside). You need to know the mail server for the recipients domain. To get that you must do an DNS query for the MX server of the destination domain. b) Once you got the socket opened to that mail server you need to understand the SMTP protocol to talk correctly to the server and transfer the message. c) While a and b can be done (though it requires quite a bit of reading the corresponding RFCs) the killer is that most mail servers nowadays don't accept mail from random machines but only from the dedicated mail servers from the domain the email is coming from. So unless the machine sending the mail is marked in DNS as a mail server for the domain (i.e., has an MX record) the mail won't get accepted. d) And, if you want to talk to your own mail server to get it to pass on the email on, many don't accept emails anymore without encryption, so you also beed to know how to deal with SSL/TLS. On a UNIX system you'd better install and properly configure a MTA (mail transport agent) that passes on the email to the mail server for the senders domain that then forwards it to the correct mail server on the receiving end. This typically is done by spawning the 'sendmail' program (but which often is a symbolic link to the actual MTA installed on the machine) and let it deal with the details of handling the mail. The nice old times when you could send out an email to your boss, looking to the uninitiated as coming from 'god@heaven', are, thanks to spam, over since a number of years. If there's no usable MTA on the machine you intend to send mails from you're screwed. And, sorry, no idea how to do it under Windows... Regards, Jens -- \ Jens Thoms Toerring ___ jt@toerring.de \__________________________ http://toerring.de