Discussion:
Problems sending mail about smtp
牟林海
2010-11-12 01:23:29 UTC
Permalink
Hello
When I use smtp to send mail, there will be following the situation, before the use of no such situation, I think that not sending HELO to continue to the other¡£
This is the code I write, is there a mistake?

curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_URL, "smtp.gmail.com");
curl_easy_setopt(curl, CURLOPT_PORT, 25);

curl_easy_setopt(curl, CURLOPT_MAIL_FROM, "<********@gmail.com>");

slist = curl_slist_append(slist, "<*******@gmail.com>");
curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, slist);

curl_easy_setopt(curl, CURLOPT_USERNAME, "*******");
curl_easy_setopt(curl, CURLOPT_PASSWORD, "********");
curl_easy_setopt(curl, CURLOPT_READDATA, fp);
curl_easy_setopt(curl, CURLOPT_READFUNCTION, read_data);




* About to connect() to smtp.gmail.com port 25 (#0)
* Trying 74.125.127.109... * connected
* Connected to smtp.gmail.com (74.125.127.109) port 25 (#0)
* Server auth using Basic with user 'mulh0117'
GET / HTTP/1.1
Authorization: Basic bXVsaDAxMTc6bWxoNjMzMDMwMA==
Host: smtp.gmail.com:25
Accept: */*

220 mx.google.com ESMTP w5sm469947ybe.10
502 5.5.1 Unrecognized command. w5sm469947ybe.10
* Connection #0 to host smtp.gmail.com left intact
* Closing connection #0



--



(Mu LinHai)
Dan Fandrich
2010-11-12 08:05:10 UTC
Permalink
Post by 牟林海
Hello
When I use smtp to send mail, there will be following the situation, before the
use of no such situation, I think that not sending HELO to continue to the
other¡£
This is the code I write, is there a mistake?
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_URL, "smtp.gmail.com");
The mistake is in this line: the value you set is not a URL. Therefore,
curl guesses what protocol you're asking for and in this case it guesses
wrong. Use an SMTP URL here, like smtp://smtp.gmail.com
Post by 牟林海
Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
牟林海
2010-11-12 08:36:33 UTC
Permalink
Post by Dan Fandrich
Post by 牟林海
Hello
When I use smtp to send mail, there will be following the situation, before the
use of no such situation, I think that not sending HELO to continue to the
other¡£
This is the code I write, is there a mistake?
curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);
curl_easy_setopt(curl, CURLOPT_HEADER, 1L);
curl_easy_setopt(curl, CURLOPT_USE_SSL, CURLUSESSL_ALL);
curl_easy_setopt(curl, CURLOPT_URL, "smtp.gmail.com");
The mistake is in this line: the value you set is not a URL. Therefore,
curl guesses what protocol you're asking for and in this case it guesses
wrong. Use an SMTP URL here, like smtp://smtp.gmail.com
Post by 牟林海
Dan
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Thanks!
but when i use "smtp://smtp.gmail.com" , it shows like this:
* Protocol smtp not supported or disabled in libcurl
* Unsupported protocol

***@nms-desktop:~/work/test/curl$ curl --version
curl 7.21.1 (i686-pc-linux-gnu) libcurl/7.21.1 zlib/1.2.3.3 libidn/1.15
Protocols: dict file ftp http imap ldap pop3 rtsp smtp telnet tftp
Features: IDN IPv6 Largefile libz

Is there any mistake Thanks.
Daniel Stenberg
2010-11-12 08:57:57 UTC
Permalink
Post by 牟林海
* Protocol smtp not supported or disabled in libcurl
* Unsupported protocol
curl 7.21.1 (i686-pc-linux-gnu) libcurl/7.21.1 zlib/1.2.3.3 libidn/1.15
Protocols: dict file ftp http imap ldap pop3 rtsp smtp telnet tftp
Features: IDN IPv6 Largefile libz
Then you probably have two libcurls installed. One older version that your app
seems to link against and one newer that your command line tool uses...
--
/ daniel.haxx.se
Michael Wood
2010-11-13 19:39:57 UTC
Permalink
2010/11/12 牟林海 <***@163.com>:
[...]
Post by 牟林海
* About to connect() to smtp.gmail.com port 25 (#0)
*   Trying 74.125.127.109... * connected
* Connected to smtp.gmail.com (74.125.127.109) port 25 (#0)
* Server auth using Basic with user 'mulh0117'
GET / HTTP/1.1
Authorization: Basic bXVsaDAxMTc6bWxoNjMzMDMwMA==
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Please note that you have given your username and password to
everybody who reads this mailing list. You should change your
password.
--
Michael Wood <***@gmail.com>
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etique
Continue reading on narkive:
Loading...