1 /***************************************************************************
3 * Project ___| | | | _ \| |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
8 * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at http://curl.haxx.se/docs/copyright.html.
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
21 ***************************************************************************/
24 #include <curl/curl.h>
26 /* This is a simple example showing how to expand an email mailing list.
30 * 1) This example requires libcurl 7.34.0 or above.
31 * 2) Not all email servers support this command.
38 struct curl_slist *recipients = NULL;
40 curl = curl_easy_init();
42 /* This is the URL for your mailserver */
43 curl_easy_setopt(curl, CURLOPT_URL, "smtp://mail.example.com");
45 /* Note that the CURLOPT_MAIL_RCPT takes a list, not a char array */
46 recipients = curl_slist_append(recipients, "Friends");
47 curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
49 /* Set the EXPN command */
50 curl_easy_setopt(curl, CURLOPT_CUSTOMREQUEST, "EXPN");
52 /* Perform the custom request */
53 res = curl_easy_perform(curl);
55 /* Check for errors */
57 fprintf(stderr, "curl_easy_perform() failed: %s\n",
58 curl_easy_strerror(res));
60 /* Free the list of recipients */
61 curl_slist_free_all(recipients);
63 /* Curl won't send the QUIT command until you call cleanup, so you should
64 * be able to re-use this connection for additional requests. It may not be
65 * a good idea to keep the connection open for a very long time though
66 * (more than a few minutes may result in the server timing out the
67 * connection) and you do want to clean up in the end.
69 curl_easy_cleanup(curl);