library/src/network/email/BP-EmailSMTP.cc
// sends an email over a given session
sends an email over a given session
sends an email over a given session
BP_ERROR_T BP_SendSMTPEmailMessage(P_BP_EMAIL_SMTP_SESSION session, P_BP_EMAIL_SMTP_MESSAGE message)
{
	if(!session || !message)
		return ERR_FAILURE;
	size_t n = 0;
	CURLcode res;
	struct upload_status upload_ctx;
	upload_ctx.payload_text = (char **) message->message_body;
	upload_ctx.lines_read = 0;
	curl_easy_setopt(session->curl, CURLOPT_MAIL_FROM, message->mail_from);
	struct curl_slist *recipients = NULL;
	 from array
	for(n=0; n < message->recipient_cnt; n++)
	{
		recipients = curl_slist_append(recipients, message->recipients[n]);
	}
	 in curl
	curl_easy_setopt(session->curl, CURLOPT_MAIL_RCPT, recipients);
	curl_easy_setopt(session->curl, CURLOPT_READFUNCTION, payload_source);
	curl_easy_setopt(session->curl, CURLOPT_READDATA,     &upload_ctx);
	curl_easy_setopt(session->curl, CURLOPT_VERBOSE, 1L);
	res = curl_easy_perform(session->curl);
	curl_slist_free_all(recipients);
	return ERR_SUCCESS;
}
BP_ERROR_T BP_SendSMTPEmailMessage ( P_BP_EMAIL_SMTP_SESSION session , P_BP_EMAIL_SMTP_MESSAGE message ) { if ( ! session || ! message ) return ERR_FAILURE ; size_t n = 0 ; CURLcode res ; struct upload_status upload_ctx ; upload_ctx . payload_text = ( char * * ) message -> message_body ; upload_ctx . lines_read = 0 ; curl_easy_setopt ( session -> curl , CURLOPT_MAIL_FROM , message -> mail_from ) ; struct curl_slist * recipients = NULL ; for ( n = 0 ; n < message -> recipient_cnt ; n ++ ) { recipients = curl_slist_append ( recipients , message -> recipients [ n ] ) ; } curl_easy_setopt ( session -> curl , CURLOPT_MAIL_RCPT , recipients ) ; curl_easy_setopt ( session -> curl , CURLOPT_READFUNCTION , payload_source ) ; curl_easy_setopt ( session -> curl , CURLOPT_READDATA , & upload_ctx ) ; curl_easy_setopt ( session -> curl , CURLOPT_VERBOSE , 1L ) ; res = curl_easy_perform ( session -> curl ) ; curl_slist_free_all ( recipients ) ; return ERR_SUCCESS ; }
sends an email over a given session
sends an email over a given session
// check for session and message and insure that they are set // general purpose iterator // upload context structure // payload text // mail from // set recipients // set recipients from array // set recipients in curl // set read data function // set read data // set verbosity level (debug) // perform curl task // destroy slist before returning // return indicating success