- You need to know what server to use. That is easy for google mail and smtp.gmail.com will do it.
- You need to know your login credentials. Your account should have 2 Factor Authentication. But you never pass your gmail password to an application directly. You go to the google website, login and then create an app-specific password for smtp. The advantage is that you can disable that password later, if it got stolen and create a new one.
- You need to know the port to use. Basically port 25, 465 and 587 all can work. But 25 and 587 connect in plain text and do the TLS upgrade later after discussing the details of the supported encryption variants. For port 465, the first package is encrypted and for that we would tell the plugin to use TLS directly. That is our UseSSL flag, you can set when using port 465. To set the port, please either put in the server, e.g. "smtp.gmail.com:587" or later set it on the CURL object with OptionPort. For gmail the default port 25 works just fine here.
- You need to know what TLS version is allowed. For our example we don't need to set an explicit version. CURL now tries TLS 1.3 and falls back to version 1.2 if the server doesn't support it. But you can set a version as minimum.
- Since gmail doesn't do plain text, we tell CURL to require SSL with OptionUseSSL = kUseSSLall.
When everything is setup correctly, the following code should send an email just fine:
Let us know if you have questions. We use the mail server from our web hoster for sending out all our emails. For newsletter we got an extra account to send without a limiting hourly capacity limit. And for you it may be worth to get an email server at your hoster with your own domain, so your emails have your own branding and not the gmail email addresss.
Please don't hesitate to contact us with questions.