Hi, I am trying to send a mail using SMTP with libcurl. I manage to do it using command line option i use the command:
curl --ssl --mail-from "<[email protected]>" --mail-rcpt "< [email protected]>" -v --url smtp://smtp.gmail.com -u harshcalsoft -T text but when i am trying to do it through a C program using curl library i am getting a "authentication required" error. I have tried the CURLOPT_USENAME and CUROPT_PASSWORD options as well. I have use the CURLOPT_HTTPAUTH option as well but to no avail. password.Previously i was using URL 'smtp:// smtp.gmail.com' along with CURLOPT_USE_SSL option which was set to CURLUSESSL_ALL. But the ssl handshake was failing so instead now i am using "smtps://smtp:gmail.com" the verification is going through fine but i get the "authentication required" error. The code looks like this: curl_easy_setopt(curl,CURLOPT_VERBOSE, 1); curl_easy_setopt(curl,CURLOPT_READDATA, fd); curl_easy_setopt(curl,CURLOPT_URL,"smtps://smtp.gmail.com"); curl_easy_setopt(curl,CURLOPT_MAIL_FROM, "<[email protected] >"); rcpt = curl_slist_append(rcpt,"<[email protected]>"); curl_easy_setopt(curl,CURLOPT_MAIL_RCPT, rcpt); curl_easy_setopt (curl, CURLOPT_USERPWD, "username:password"); res = curl_easy_perform(curl); printf("The return code is %d\n",res); curl_slist_free_all(rcpt); But I am getting the following error: * About to connect() to smtp.gmail.com port 465 (#0) * Trying 74.125.155.109... * connected * Connected to smtp.gmail.com (74.125.155.109) port 465 (#0) * successfully set certificate verify locations: * CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none * SSL connection using RC4-MD5 * Server certificate: * subject: C=US; ST=California; L=Mountain View; O=Google Inc; CN= smtp.gmail.com * start date: 2010-04-22 20:02:45 GMT * expire date: 2011-04-22 20:12:45 GMT * common name: smtp.gmail.com (matched) * issuer: C=US; O=Google Inc; CN=Google Internet Authority * SSL certificate verify ok. < 220 mx.google.com ESMTP q36sm5928606yba.0 > EHLO localhost < 250-mx.google.com at your service, [219.91.201.210] < 250-SIZE 35651584 < 250-8BITMIME < 250-AUTH LOGIN PLAIN XOAUTH < 250-ENHANCEDSTATUSCODES < 250 PIPELINING > MAIL FROM:<[email protected]> < 530-5.5.1 Authentication Required. Learn more at < 530 5.5.1 http://mail.google.com/support/bin/answer.py?answer=14257q36sm5928606yba.0 * Access denied: 530 > QUIT < 221 2.0.0 closing connection q36sm5928606yba.0 * Closing connection #0 * Login denied The return code is 67 Plz can anyone help what am i missing here.
------------------------------------------------------------------- List admin: http://cool.haxx.se/list/listinfo/curl-library Etiquette: http://curl.haxx.se/mail/etiquette.html
