首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从pjsip发送电子邮件。是否有可用于发送电子邮件的默认方法

如何从pjsip发送电子邮件。是否有可用于发送电子邮件的默认方法
EN

Stack Overflow用户
提问于 2018-03-23 19:53:24
回答 1查看 85关注 0票数 2

我有一个呼叫应用程序的pjsip项目。我有一个像curl.Is这样的外部包,它可以添加一个外部包到pjsip应用程序或如何添加外部包到pjsip.Is有任何默认的方法可用于发送电子邮件。这件事我想check.please帮助提前解决我的issues.Thanks。

当设备注册失败时,我想从pjsip发送电子邮件。

代码语言:javascript
复制
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <curl/curl.h>

using namespace std;

#define CURL_STATICLIB 

#define FROM    "princetomy12@gmail.com"
#define TO      "sangeethjohn01@gmail.com"



static const char *payload_text[] = {
    "To: " TO "\r\n",
    "From: " FROM "\r\n",
    "Subject: SMTP TLS example message\r\n",
    NULL
};

struct upload_status {
    int lines_read;
};

static size_t payload_source(void *ptr, size_t size, size_t nmemb, void *userp)
{
    struct upload_status *upload_ctx = (struct upload_status *)userp;
    const char *data;

    if ((size == 0) || (nmemb == 0) || ((size*nmemb) < 1)) {
        return 0;
    }

    data = payload_text[upload_ctx->lines_read];

    if (data) {
        size_t len = strlen(data);
        memcpy(ptr, data, len);
        upload_ctx->lines_read++;

        return len;
    }

    return 0;
}

int main(void)
{

    system("pause");
    //return (int)res;
}
static int  call_send_email()
{

    CURL *curl;
    CURLcode res = CURLE_OK;
    struct curl_slist *recipients = NULL;
    struct upload_status upload_ctx;

    upload_ctx.lines_read = 0;


    cout << "\nstart pgm";
    curl = curl_easy_init();
    if (curl) {
        curl_easy_setopt(curl, CURLOPT_USERNAME, "princetomy12@gmail.com");
        curl_easy_setopt(curl, CURLOPT_PASSWORD, "********");
        curl_easy_setopt(curl, CURLOPT_URL, "smtp://smtp.gmail.com:587");
        curl_easy_setopt(curl, CURLOPT_USE_SSL, (long)CURLUSESSL_ALL);
        curl_easy_setopt(curl, CURLOPT_CAINFO, "google.pem");
        curl_easy_setopt(curl, CURLOPT_MAIL_FROM, FROM);
        recipients = curl_slist_append(recipients, TO);
        //curl_easy_setopt(curl, CURLOPT_FILE, "edgE0DF.tmp"); 
        curl_easy_setopt(curl, CURLOPT_MAIL_RCPT, recipients);
        curl_easy_setopt(curl, CURLOPT_READFUNCTION, payload_source);
        curl_easy_setopt(curl, CURLOPT_READDATA, &upload_ctx);
        curl_easy_setopt(curl, CURLOPT_UPLOAD, 1L);
        curl_easy_setopt(curl, CURLOPT_VERBOSE, 1L);

        res = curl_easy_perform(curl);
        cout << "check status";
        if (res != CURLE_OK)
            fprintf(stderr, "curl_easy_perform() failed: %s\n",
                curl_easy_strerror(res));

        curl_slist_free_all(recipients);

        curl_easy_cleanup(curl);
    }
    cout << "completed execution";

    return 1;
}
EN

回答 1

Stack Overflow用户

发布于 2018-03-29 14:16:25

我已经为电子邮件发送创建了单独的项目,并在pjsip项目中包括该项目。我已经在pjsip中包含了头文件并从设备注册失败的情况下调用了我的函数。我认为这种解决方法更好。我认为没有其他选择可以使用pjsip的内置函数发送电子邮件。

在设备注册失败的情况下,pjsip

  • 从项目调用我的方法在visual studio解决方案中创建了单独的project.

  • included项目。
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49449105

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档