examples: Standardised username and password settings for all email examples
Replaced the use of CURLOPT_USERPWD for the preferred CURLOPT_USERNAME and CURLOPT_PASSWORD options and used the same username and password for all email examples which is the same as that used in the test suite.
This commit is contained in:
parent
84a9f092dc
commit
5220c1d692
@ -84,7 +84,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will create a new message 100. Note that you should perform an
|
||||
* EXAMINE command to obtain the UID of the next message to create and a
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is source mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is just the server URL */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com");
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will fetch message 1 from the user's inbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX/;UID=1");
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will list the folders within the user's mailbox. If you want to
|
||||
* list the folders within a specific folder, for example the inbox, then
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
@ -36,7 +36,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is the mailbox folder to select */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "imap://imap.example.com/INBOX");
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -30,7 +30,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will only fetch the message with ID "1" of the given mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://user@pop.example.com/1");
|
||||
@ -61,13 +62,15 @@ int main(void)
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
* | (__| |_| | _ <| |___
|
||||
* \___|\___/|_| \_\_____|
|
||||
*
|
||||
* Copyright (C) 1998 - 2011, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
* Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||
*
|
||||
* This software is licensed as described in the file COPYING, which
|
||||
* you should have received as part of this distribution. The terms
|
||||
@ -30,7 +30,8 @@ int main(void)
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERPWD, "user:password");
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This will list every message of the given mailbox */
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "pop3s://user@pop.example.com/");
|
||||
@ -61,13 +62,15 @@ int main(void)
|
||||
|
||||
/* Perform the request, res will get the return code */
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
/* Check for errors */
|
||||
if(res != CURLE_OK)
|
||||
fprintf(stderr, "curl_easy_perform() failed: %s\n",
|
||||
curl_easy_strerror(res));
|
||||
|
||||
/* always cleanup */
|
||||
/* Always cleanup */
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -29,8 +29,6 @@
|
||||
/*
|
||||
* This is the list of basic details you need to tweak to get things right.
|
||||
*/
|
||||
#define USERNAME "user@example.com"
|
||||
#define PASSWORD "123qwerty"
|
||||
#define SERVER "smtp.example.com"
|
||||
#define PORT ":587" /* it is a colon+port string, but you can set it
|
||||
to "" to use the default port */
|
||||
@ -126,8 +124,8 @@ int main(void)
|
||||
recipients = curl_slist_append(recipients, CC);
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, "smtp://" SERVER PORT);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, USERNAME);
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, PASSWORD);
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
|
||||
curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
|
||||
curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
|
||||
|
@ -24,8 +24,9 @@
|
||||
#include <curl/curl.h>
|
||||
|
||||
/* This is a simple example showing how to send mail using libcurl's SMTP
|
||||
* capabilities. It builds on the smtp-send.c example, adding some
|
||||
* authentication and transport security.
|
||||
* capabilities. It builds on the smtp-send.c example to add authentication
|
||||
* and, more importantly, transport security to protect the authentication
|
||||
* details from being snooped.
|
||||
*/
|
||||
|
||||
#define FROM "<sender@example.org>"
|
||||
@ -84,6 +85,10 @@ int main(void)
|
||||
|
||||
curl = curl_easy_init();
|
||||
if(curl) {
|
||||
/* Set username and password */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "secret");
|
||||
|
||||
/* This is the URL for your mailserver. Note the use of port 587 here,
|
||||
* instead of the normal SMTP port (25). Port 587 is commonly used for
|
||||
* secure mail submission (see RFC4403), but you should use whatever
|
||||
@ -110,12 +115,6 @@ int main(void)
|
||||
* docs/SSLCERTS for more information. */
|
||||
curl_easy_setopt(curl, CURLOPT_CAINFO, "/path/to/certificate.pem");
|
||||
|
||||
/* A common reason for requiring transport security is to protect
|
||||
* authentication details (user names and passwords) from being "snooped"
|
||||
* on the network. Here is how the user name and password are provided: */
|
||||
curl_easy_setopt(curl, CURLOPT_USERNAME, "user@example.net");
|
||||
curl_easy_setopt(curl, CURLOPT_PASSWORD, "P@ssw0rd");
|
||||
|
||||
/* Value for envelope reverse-path */
|
||||
curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user