Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
TLMSP curl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CYBER - Cyber Security
TS 103 523 MSP
TLMSP
TLMSP curl
Commits
190e41f8
Commit
190e41f8
authored
11 years ago
by
Steve Holme
Browse files
Options
Downloads
Patches
Plain Diff
examples: Added comments to SMTP multi example based on other MAIL examples
parent
5d25d626
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
docs/examples/smtp-multi.c
+24
-8
24 additions, 8 deletions
docs/examples/smtp-multi.c
with
24 additions
and
8 deletions
docs/examples/smtp-multi.c
+
24
−
8
View file @
190e41f8
...
...
@@ -114,23 +114,38 @@ int main(void)
if
(
!
mcurl
)
return
2
;
/* This is the URL for your mailserver */
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
"smtp://mail.example.com"
);
/* Note that this option isn't strictly required, omitting it will result in
* libcurl sending the MAIL FROM command with empty sender data. All
* autoresponses should have an empty reverse-path, and should be directed
* to the address in the reverse-path which triggered them. Otherwise, they
* could cause an endless loop. See RFC 5321 Section 4.5.5 for more details.
*/
curl_easy_setopt
(
curl
,
CURLOPT_MAIL_FROM
,
FROM
);
/* Add two recipients, in this particular case they correspond to the
* To: and Cc: addressees in the header, but they could be any kind of
* recipient. */
recipients
=
curl_slist_append
(
recipients
,
TO
);
recipients
=
curl_slist_append
(
recipients
,
CC
);
curl_easy_setopt
(
curl
,
CURLOPT_MAIL_RCPT
,
recipients
);
curl_easy_setopt
(
curl
,
CURLOPT_URL
,
"smtp://smtp.example.com"
);
/* We're using a callback function to specify the payload (the headers and
* body of the message). You could just use the CURLOPT_READDATA option to
* specify a FILE pointer to read from. */
curl_easy_setopt
(
curl
,
CURLOPT_READFUNCTION
,
payload_source
);
curl_easy_setopt
(
curl
,
CURLOPT_READDATA
,
&
upload_ctx
);
curl_easy_setopt
(
curl
,
CURLOPT_UPLOAD
,
1L
);
curl_easy_setopt
(
curl
,
CURLOPT_MAIL_FROM
,
FROM
);
curl_easy_setopt
(
curl
,
CURLOPT_MAIL_RCPT
,
recipients
);
/* Tell the multi stack about our easy handle */
curl_multi_add_handle
(
mcurl
,
curl
);
/* Record the start time which we can use later */
mp_start
=
tvnow
();
/*
w
e start some action by calling perform right away */
/*
W
e start some action by calling perform right away */
curl_multi_perform
(
mcurl
,
&
still_running
);
while
(
still_running
)
{
...
...
@@ -148,7 +163,7 @@ int main(void)
FD_ZERO
(
&
fdwrite
);
FD_ZERO
(
&
fdexcep
);
/*
s
et a suitable timeout to play around with */
/*
S
et a suitable timeout to play around with */
timeout
.
tv_sec
=
1
;
timeout
.
tv_usec
=
0
;
...
...
@@ -161,7 +176,7 @@ int main(void)
timeout
.
tv_usec
=
(
curl_timeo
%
1000
)
*
1000
;
}
/*
g
et file descriptors from the transfers */
/*
G
et file descriptors from the transfers */
curl_multi_fdset
(
mcurl
,
&
fdread
,
&
fdwrite
,
&
fdexcep
,
&
maxfd
);
/* In a real-world program you OF COURSE check the return code of the
...
...
@@ -188,7 +203,10 @@ int main(void)
}
}
/* Free the list of recipients */
curl_slist_free_all
(
recipients
);
/* Always cleanup */
curl_multi_remove_handle
(
mcurl
,
curl
);
curl_multi_cleanup
(
mcurl
);
curl_easy_cleanup
(
curl
);
...
...
@@ -196,5 +214,3 @@ int main(void)
return
0
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment