Announcement

Collapse
No announcement yet.

Sent e-mail using API

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Sent e-mail using API

    How can i sent e-mail from espo using API ?

  • #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


    • #3
      Can you share with me some example?

      Comment


      • #4
        Of API using?
        http://forum.espocrm.com/forum/devel...empty-response

        Comment


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

          Comment


          • #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


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

              Comment


              • #8
                Which fields are require?

                Comment


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

                  body could be empty

                  Comment


                  • #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


                    • #11
                      Hi Kurt,

                      1) fromName is defined in CRM (in SMTP configuration or User Name). You can set only 'from' in parameters
                      https://github.com/espocrm/espocrm/b...Email.php#L116
                      https://github.com/espocrm/espocrm/b...ender.php#L158

                      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
                      https://github.com/espocrm/espocrm/b...ifications.php
                      https://github.com/espocrm/espocrm/b...tification.php

                      Comment


                      • #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...
                        X