Created
May 29, 2011 23:00
-
-
Save anonymous/998214 to your computer and use it in GitHub Desktop.
Segfault on Windows, not on Fedora
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import etc.c.curl; | |
import std.string; | |
import etc.curl; | |
import std.stdio; | |
import std.c.stdio : fread; | |
extern(C) size_t read_callback(void* ptr, size_t size, size_t nmemb, shared(_iobuf)* pdata) | |
{ | |
return fread(ptr, size, nmemb, pdata); | |
} | |
void main() | |
{ | |
auto curl = new Curl(); | |
auto f = File("test.txt", "rb"); | |
scope(exit) f.close(); | |
//Uncomment the line below and it will work on Windows | |
//curl.set(CurlOption.readfunction, cast(void*)&read_callback); | |
curl.set(CurlOption.infile, cast(void*)f.getFP); //this is the data. | |
curl.set(CurlOption.infilesize_large, f.size); | |
curl.set(CurlOption.timeout, 60); | |
curl.set(CurlOption.use_ssl, CurlUseSSL.all); | |
curl.set(CurlOption.ssl_verifypeer, 0); | |
curl.set(CurlOption.ssl_verifyhost, 2); | |
curl.set(CurlOption.url, "smtps://smtp.gmail.com"); | |
curl.set(CurlOption.mail_from, "<SENDER.USERNAME@gmail.com>"); | |
curl.set(CurlOption.userpwd, "SENDER.USERNAME@gmail.com:PASSWORD"); | |
curl_slist* rcptl = null; | |
rcptl = curl_slist_append(rcptl, cast(char*)toStringz("<RECIPIENT@gmail.com>")); | |
curl.set(CurlOption.mail_rcpt, cast(void*)rcptl); | |
curl.perform(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment