I am trying to send an email using CSmtp
http://www.codeproject.com/Articles/98355/SMTP-Client-with-SSL-TLS
These lines of code are harmful here:
if((sockAddr.sin_addr.s_addr = inet_addr(szServer)) == INADDR_NONE)
{
LPHOSTENT host;
host = gethostbyname(szServer);
if (host)
memcpy(&sockAddr.sin_addr,host->h_addr_list[0],host->h_length);
else
{
close(hSocket);
closesocket(hSocket);
throw ECSmtp(ECSmtp::WSA_GETHOSTBY_NAME_ADDR);
}
}
inet_addr
and gethostbyname
no longer works.
'inet_addr': Use inet_pton() or InetPton() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
'gethostbyname': Use getaddrinfo() or GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to disable deprecated API warnings
How can I make this work with inet_pton()
and getaddrinfo()
? I tried to find a solution, but havent found anything else so far ...
Thanks!
source
share