Sent e-mail using API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • emillod
    Active Community Member
    • Apr 2017
    • 1541

    #1

    Sent e-mail using API

    How can i sent e-mail from espo using API ?
  • tanya
    Senior Member
    • Jun 2014
    • 4308

    #2
    Hello
    The easiest way is to do the action in system with opened browser console. In network tab you can see the url and all the parameters

    Comment

    • emillod
      Active Community Member
      • Apr 2017
      • 1541

      #3
      Can you share with me some example?

      Comment

      • tanya
        Senior Member
        • Jun 2014
        • 4308

        #4
        Of API using?
        Hello, I'm trying to upload contact's document via EspoCRM API v1. The first thing I do is send POST fields to 'api/v1/Attachment'. My POST fields look like this:

        Comment

        • emillod
          Active Community Member
          • Apr 2017
          • 1541

          #5
          I dont know did you understand me
          I want to sent e-mail using API POST to client. Is that possible?

          Comment

          • tanya
            Senior Member
            • Jun 2014
            • 4308

            #6
            I did understand. You could see this, if you opened browser console.

            $postFields = json_encode(array(
            "assignedUserId" => "1",
            "body" => "<p>text3</p>",
            "bodyPlain" => "text",
            "isHtml" => true,
            "status" => "Sending",
            "subject" => "sub3",
            "from" => emailFrom,
            "to" => emailTo
            ));

            $url = $espoUrl . "/api/v1/Email";
            $httpMethod = "POST";

            Comment

            • emillod
              Active Community Member
              • Apr 2017
              • 1541

              #7
              I already check that and i'm using console from browser, but i can't find list of fields

              Comment

              • emillod
                Active Community Member
                • Apr 2017
                • 1541

                #8
                Which fields are require?

                Comment

                • tanya
                  Senior Member
                  • Jun 2014
                  • 4308

                  #9
                  $postFields = json_encode(array(
                  "body" => "<p>text3</p>",
                  "status" => "Sending",
                  "subject" => "sub3",
                  "from" => emailFrom,
                  "to" => emailTo
                  ));

                  body could be empty

                  Comment

                  • Kurt
                    Member
                    • Jan 2018
                    • 37

                    #10
                    Hi Tanya, I have a couple of related questions:

                    1) How do you set the fromName with this approach? I tried doing something like from = "Some Name <email@example.com>" which is a valid email string for other libraries I've worked with but that choked, and I also tried passing a fromName param but it doesn't seem to get used.

                    2) Is there a way to queue up multiple emails without sending, and then trigger them being sent in bulk? I thought maybe I could put them in some other status first and then do a bunch of updates to status = "Sending" but I think that would still behave in a synchronous manner since it looks like there is a status check in a function that runs after the update.

                    Thanks.

                    Comment

                    • tanya
                      Senior Member
                      • Jun 2014
                      • 4308

                      #11
                      Hi Kurt,

                      1) fromName is defined in CRM (in SMTP configuration or User Name). You can set only 'from' in parameters

                      EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.


                      2) no, this feature is not implemented. You can add checkbox in Entity Manager (like email is ready to send), save Emails as draft, and develop a job for sending ready emails
                      Example
                      EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

                      EspoCRM – Open Source CRM Application. Contribute to espocrm/espocrm development by creating an account on GitHub.

                      Comment

                      • Kurt
                        Member
                        • Jan 2018
                        • 37

                        #12
                        For #1, I set the From Name in the Outbound Emails configuration so when the System user sends email it uses the From Name that I'm aiming for. Is there a way that I can send Emails via API that get sent out by the System user instead of the User that created the Email record? For example I'm accessing the API as Admin to create Emails so the From Name shows up as "Admin", but I'd like it to just send as the system somehow.

                        Thanks for your help.

                        Comment

                        Working...