Hola Paco,
la clase de Matteo Baccan sólo permite los siguientes algoritmos:
HS256
HS384
HS512
Hacen falta algunos más:
Muchas gracias.
Saludos,
#include "hbcurl.ch"
function main()
local hCredentials := { "type" => "gmail", "user" => "mi-user@gmail.com", "key" => "mi_token_de_seguridad_gmail" }
? 'SEND', Send_Gmail( hCredentials[ 'user' ], hCredentials[ 'key' ], 'Charly', 'charly@su-mail.com', 'Test...', 'Hola...' )
retu nil
//----------------------------------------------------------------------------//
function Send_Gmail( cUser_From, cKey, cTo_Alias, cTo_Address, cTitle, cMsg )
local d := date()
local cDate := CDow(d) + ', ' + ltrim(str(day(d))) + ' ' + cMonth(d) + ' ' + ltrim(str(year(d))) + ' ' + time()
local cTempFile := TempFile( hb_getenv( 'PRGPATH' ) + '/data' , 'txt' )
LOCAL hCurl, uValue, nHandle, cTxt
// "Date: Tue, 3 Feb 2021 20:40:16" + CRLF + CRLF +;
if ! empty( hCurl := curl_easy_init() )
cTxt := "From: Chatbour <" + cUser_From + ">" + CRLF +;
"To: " + cTo_Alias + " <" + Alltrim( cTo_Address) + ">" + CRLF+;
"Subject: " + cTitle + CRLF +;
"Date: " + cDate + CRLF + CRLF +;
cMsg
nHandle := Fcreate(cTempFile)
Fwrite(nHandle,cTxt )
FClose(nHandle)
curl_easy_setopt(hCurl, HB_CURLOPT_USE_SSL, HB_CURLUSESSL_TRY )
curl_easy_setopt(hCurl, HB_CURLOPT_UPLOAD )
curl_easy_setopt(hCurl, HB_CURLOPT_USERNAME, cUser_From )
curl_easy_setopt(hCurl, HB_CURLOPT_PASSWORD, cKey )
curl_easy_setopt(hCurl, HB_CURLOPT_URL, "smtps://smtp.gmail.com:465")
curl_easy_setopt(hCurl, HB_CURLOPT_PROTOCOLS, hb_bitOr( HB_CURLPROTO_SMTPS, HB_CURLPROTO_SMTP ) )
curl_easy_setopt(hCurl, HB_CURLOPT_TIMEOUT_MS, 5000 )
curl_easy_setopt(hCurl, HB_CURLOPT_FOLLOWLOCATION, 1)
curl_easy_setopt(hCurl, HB_CURLOPT_SSL_VERIFYPEER, 0)
curl_easy_setopt(hCurl, HB_CURLOPT_MAIL_FROM, cUser_From )
curl_easy_setopt(hCurl, HB_CURLOPT_MAIL_RCPT, { cTo_Address })
curl_easy_setopt(hCurl, HB_CURLOPT_VERBOSE, 0)
curl_easy_setopt(hCurl, HB_CURLOPT_UPLOAD, 1)
curl_easy_setopt(hCurl, HB_CURLOPT_UL_FILE_SETUP, cTempFile )
IF (nret:=curl_easy_perform( hCurl )) == 0
uValue := nret
ELSE
uValue := nret
ENDIF
ENDIF
fErase( cTempFile )
curl_easy_cleanup( hCurl )
RETURN uValue
//----------------------------------------------------------------------------//
curl_easy_setopt( hCurl, HB_CURLOPT_MIMEPOST, { ;
{ "filedata" => "d:\discoc\send\_Result.pdf" } } )
#define HB_CURLE_LOGIN_DENIED 67 /* user, password or similar was not accepted and we failed to login */
Y no olvidaros de parametrizar vuestra cuenta de gmail a doble verificacion y opbtener la key.
from http://fivetechsupport.com/forums/viewt ... 75#p2501962.3 Use this password instead of gmail's password.
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: No registered users and 8 guests