]> granicus.if.org Git - curl/commitdiff
examples: Standardised username and password settings for all email examples
authorSteve Holme <steve_holme@hotmail.com>
Sat, 4 Jan 2014 18:10:18 +0000 (18:10 +0000)
committerSteve Holme <steve_holme@hotmail.com>
Sat, 4 Jan 2014 18:12:02 +0000 (18:12 +0000)
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.

13 files changed:
docs/examples/imap-append.c
docs/examples/imap-copy.c
docs/examples/imap-create.c
docs/examples/imap-delete.c
docs/examples/imap-examine.c
docs/examples/imap-fetch.c
docs/examples/imap-list.c
docs/examples/imap-search.c
docs/examples/imap-store.c
docs/examples/pop3s.c
docs/examples/pop3slist.c
docs/examples/smtp-multi.c
docs/examples/smtp-tls.c

index ce8d0421bd43fc02a9f236e9346e36a72a9f7c1c..8f0ebcb3bfeb00b7b0f38c3963b6a7c2026ef685 100644 (file)
@@ -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
index 6c2db6f9120073db34b6d18c5b20c1f7edad7f79..fe2d91c1be1b5c201b0fc950a75d953a37b9fee3 100644 (file)
@@ -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");
index 3b55d7e798fd27061ff85dc56e36e45ce34a4502..65ddede6cacd7a4159ad3a5d88536bb27bc5cf81 100644 (file)
@@ -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");
index 2358012efb5c583523a36419a05eed9ed5bb2fdb..5113be9ab5c3dabc5d7044fefc447baf2bf0984e 100644 (file)
@@ -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");
index eb245267bc10c504b31be6dcebc1f324711ef199..a7b41c58aa0775e31d824d324669792f0e595fb2 100644 (file)
@@ -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");
index aa1f833e0301db8291ffb38c2691fbe07739ccf2..831d0dcf3f2347026d0b829d32660271adcf3f0f 100644 (file)
@@ -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");
index 45f311d52d7a35babae82291f1348f9f5d471c9b..4223052e41dff155a76befa589e413cb26f563b0 100644 (file)
@@ -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
index fcc5c528d5fc0b1edc5ee3d3d099b0152226bffa..0c1d267349100b528f72cbf35024a2749204bf61 100644 (file)
@@ -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");
index ed38db5c8e278cea14eed4118e7375bb0b619666..8f5e7d5b2e964c3d7248dfd57949a8bb15d553c2 100644 (file)
@@ -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");
index 44d7c80d0f56716fb658b94af01a648b39acba9c..368d61f2ba4e56c334101f07362fac2d6f3138fa 100644 (file)
@@ -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;
 }
index 9d9668fa0a7ad12dbfa32a67e3ecea81b850c727..cc31bfd076957d46ae965e613d71a4455c837d8b 100644 (file)
@@ -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;
 }
index 612508f316da89ddaa3dba22812cfabf69a396cb..7394f1ea825c9fe40b23437b4b4899cf500e7829 100644 (file)
@@ -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);
index 1ab7e205bcfd6cc64bb7fa3292fe0922d94c2f39..15f946586e2cabd637695eddbf9a6d5cfb9094af 100644 (file)
@@ -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);