sending email with gmail smtp ( secure layer ) in c++ - c++

does any one had success with gmail smtp servers ? smtp.gmail.com
to send emails from c++ code ?
i know its using secure layer but i have no idea how to implement such one .

This is what i used, It was for linux though, It should Technically work on windows
http://johnwiggins.net/jwsmtp/
The Tutorials are there and straigt forwards
http://johnwiggins.net/jwsmtp/example1.html
Here is a copy and paste from the site showing Ports and SMTP Server. Credit goes to john wiggins
jwsmtp::mailer mail(to.c_str( ),
from.c_str( ),
subject.c_str( ),
mailmessage.c_str( ),
smtpserver.c_str( ),
jwsmtp::mailer::SMTP_PORT,
false);
To Authenticate
mail.username("loginname");
mail.password("secret");
mail.authtype(mailer::PLAIN);
Currently only LOGIN and PLAIN authentication are supported, LOGIN by default,
to set to PLAIN call the authtype function

Your ISP could be blocking the secure SMTP port.
You could try to the same in Thunderbird and verify that the port is open first.

Sending to GMail over SSL connection on port 465 does work, and in a straightforward way. You establish connection, you do SSL initialization/handshake, then send EHLO command and it is the usual way from there. You also need login or plain authentication with the server to make it accept your messages.

Related

Can I restrict cfmail to only send mail from a given domain using cf admin

We have had issues with our server being used to send spam via cfmail to our remote SMTP server. I cannot see where it is occurring, but the emails are sent from a domain that is not one on our server.
Is there a way using ColdFusion administrator to specify that only emails showing as from someone#mydomain.com are sent to the SMTP host via the spool?
Thanks in advance,
Paul
It sounds to me like the <cfmail> side of things here is a red herring and you have got an open relay on your mail server. You seriously need to disable that immediately! If your SMTP server has to relay email for your CFML app then make sure it's not configured to relay everything, instead just for the IP address of the CF server, or for the credentials the CF server uses to connect to it.
If you don't know how to configure the relaying settings for your SMTP server, raise another question on serverfault.com asking how. Provide the exact details of your SMTP server, as well as the requirement to still allow relaying for the CF server.

How are passwords sent for websocket's authentication in CF10?

On the doc Specifying WebSocket authentication details, it did not mention how are passwords being sent from client's authenticate() JS func to server's onWSAuthenticate. Are they being sent through a secure channel? or in plain text?
Side question: what tool / browser / browser's plugin can one use to sniff through websocket's traffic?
Thank you.
username/password sent through authenticate() function is in clear-text. You can actually see that in cfwebsocket.js (its minified so search for authenticate). On server if the call is for authentication, it would invoke onWSAuthenticate() in application.cfc passing whatever username or password given to the function. So the logic of encryption/decryption/validation lies with the developer.
Any TCP monitor can be used for sniffing websocket's traffic like wireshark , TCPMon etc
Mostly just answering to further my own understanding of how this works. From the websocket.org site:
The tunnel is established by issuing an HTTP CONNECT statement to the proxy server, which requests for the proxy server to open a TCP/IP connection to a specific host and port. Once the tunnel is set up, communication can flow unimpeded through the proxy. Since HTTP/S works in a similar fashion, secure WebSockets over SSL can leverage the same HTTP CONNECT technique.
So, if this is what you're asking, it appears that just like with http/https, it's up to the developer to implement SSL encryption, which makes sense.
Sagar Ganatra also has a blog entry on the basics of Websocket Authentication with CF.

Send mail in c++ in windows using gmail as smtp relayer

Does anyone know how to send an email with an attachment(txt file) using a gmail as an smtp relayer in windows environment.I have looked at some sample code here but that was for the linux os. So far i could not find any sample code for windows.Help would be appreciated.
Google mail server will only accept secure connection, SSL or TLS. Here are the addresses and ports GMail uses: http://support.google.com/mail/bin/answer.py?hl=en&answer=13287
So, you need to use SSL/TLS-enabled socket like this one: CSslSocket - SSL/TLS enabled CSocket.
Or, if you want to implement SMTP over SSL yourself, using SChannel API, this sample will guide you through: C++ SSPI Schannel TLS example (this shows how to break through SSL and you are to complete with with SMTP plain text conversation sending an email).

Sending emails without using SMTP Server

I want that my program could send email without using Microsoft Outlook or other programs or SMTP server. Is that possible? Can I send email without connecting to SMTP server?
You can't by definition, since email gets through the recipient at least passing through the SMTP server of his/her domain.
You may send it directly to the recipient's SMTP server instead of going through the ISP's server getting its data through DNS (which is basically re-implementing a local SMTP server on your own), but it's not a good idea, since many target servers will refuse to accept your mails due to spam concerns (your connection will probably come through graylisted "residential" IP addresses, it won't have a rDNS record, ...).

how to use ssl with smtp in c++

im looking for code example or tutorial on what i need to do to code sending email
via email client ( that i already have ) that will support ssl authentication
i guess using open ssl
Boost.Asio and the Sockets Library both have SSL support. The latter has SMTP server class but unfortunately no client. I found an example client but it uses the simple C socket.h.
Update: Here are some real working examples. They all support SSL or TLS.
Msmtp: An SMTP client and SMTP plugin for mail user agents such as Mutt
sSMTP: Extremely simple MTA to get mail off the system to a Mailhub
libESMTP: lib that implements the client side of the SMTP protocol