EMailSender-master Library problem to manage email variable

Home Forums esp8266 EMailSender-master Library problem to manage email variable

Tagged: ,

Viewing 4 reply threads
  • Author
    Posts
    • #6227
      Adnan Aygunduz

        First of all, thank you so much for creating such a great library.

        My problem is:

        The code works perfectly.

        EMailSender::Response resp = emailSend.send(“xxxxx@gmail.com”, message);

        However;

        When I use it like this, it gives me an error.

        myemail=”xxxxx@gmail.com”

        EMailSender::Response resp = emailSend.send(myemail, message);

        no matching function for call to ‘EMailSender::send(String*, EMailSender::EMailMessage&)’

        Couldn’t figure out the problem. Can you please point to me to the right direction? Thanks.

      • #6261
        Renzo Mischianti
        Keymaster

          Hi Adnan,

          sorry if I response only now.

          You can use a char array pointer

          const char* emailToSend = "renzo.mischianti@gmail.com";
          EMailSender::Response resp = emailSend.send(emailToSend, message);

          I think you use a String variable for myemail, change type.

          Bye Renzo

        • #6307
          Adnan Aygunduz

            Hi Renzo,

            Thanks a lot. It worked.

            I just added .c_str() to my strings to make the conversion.

          • #8027
            windip

              Hi,

              first I want to thank you for the great lib! I had to search 2 weeks to find a simple and working way to send e-mails from esp8266!

              I send mails to multible adresses. When using an array of const char* everything works fine for me.

              const char* mail_to_list[] = {“mail_01@gmail.com”, “mail_02@yx.com”};

              If I use:  char* mail_to_list[] = {“mail_01@gmail.com”, “mail_02@yx.com”};

              to be able to write the adresses with strcpy() to the variable (from a web interface), I get the error:   “invalid conversion from ‘char**’ to ‘const char**'”

              Is there a way, to get multible e_mail adresses from other variables to be sent?

              Very thankful for any help,

              windip

              • #8037
                Renzo Mischianti
                Keymaster

                  Hi windip,
                  I think It’s better if you use an array of String instead of char*, in that situation you receive a warning like
                  ISO C++ forbids converting a string constant to 'char*' [-Wwrite-strings]

                  to manage this situation I use a simple String[].

                  This evening or tomorrow I’m going to release a new version (2.1.4) that can take a String[] or char* [] and convert It inside the library with a converter like

                  const char** toCharArray(String arr[], int num) {
                      // If we ever alloc with new with have to delete
                      const char** buffer = new const char*[num];
                  
                      for(int i = 0; i < num; i++) {
                          buffer[i] = arr[i].c_str();
                      }
                  
                      return buffer;
                  }
                  

                  and

                  const char** toCharArray(char* arr[], int num) {
                      // If we ever alloc with new with have to delete
                      const char** buffer = new const char*[num];
                  
                      for(int i = 0; i < num; i++) {
                          buffer[i] = arr[i];
                      }
                  
                      return buffer;
                  }
                  
                  

                  I think It’s what you need.

                  Bye Renzo

                   

              • #8173
                windip

                  Thank you so much for your quick response!
                  Everything works perfekt now using an array of String[3].

                  Thanks,

                  WindiP

              Viewing 4 reply threads
              • You must be logged in to reply to this topic.
              Exit mobile version