Menu

I have an error on execution.

Help
Bhiri Slim
2011-01-22
2013-12-05
  • Bhiri Slim

    Bhiri Slim - 2011-01-22

    Hi i tried this script to test sending mail with vmime :

     vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();
        try
        {
            vmime::messageBuilder mb;
            // Fill in some header fields and message body
            mb.setSubject(vmime::text("Message Subject"));
            mb.setExpeditor(vmime::mailbox("xxx"));
            mb.getRecipients().appendAddress(vmime::create<vmime::mailbox>(vmime::string("slim.it.tn@gmail.com")));
            mb.getTextPart()->setCharset(vmime::charsets::UTF_8);
            mb.getTextPart()->setText(vmime::create<vmime::stringContentHandler>("This is the text of your message..."));
            // Message construction
            vmime::ref <vmime::message> msg = mb.construct();
    //        // Output raw message data to standard output
    //        vmime::utility::outputStreamAdapter out(std::cout);
    //        msg->generate(out);
            // Create a new session
            vmime::utility::url url("smtp://smtp.gnet.tn");
            vmime::ref <vmime::net::session> sess = vmime::create<vmime::net::session>();
            // Create an instance of the transport service
            vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
            // Connect it
            tr->connect();
            //Send the message
            tr->send(msg);
            // We have finished using the service
            tr->disconnect();
        }
        // VMime exception
        catch (vmime::exception& e)
        {
            std::cerr << "vmime::exception; " << e.what() << std::endl;
        }
        // Standard exception
        catch (std::exception& e)
        {
            std::cerr << "std::exception: " << e.what() << std::endl;
        }
    

    and at execution it gives me this error :

    vmime::exception; Error while executing command 'RCPT TO': slim.it.tn@gmail.com.

    so, do you see what the problem is ?

    Thanks.

     
  • Vincent Richard

    Vincent Richard - 2011-01-22

    Hello!

    Here, the vmime::exception should actually be of type vmime::exceptions::command_error, and you can get more information about the issue (ie. the actual response from the server).

    Have a look at the exception helper in "example6".

    Vincent

     
  • Bhiri Slim

    Bhiri Slim - 2011-01-22

    Thank you,

    here is the complete error :
    **
    * vmime::exceptions::command_error
        what = Error while executing command 'RCPT TO': slim.it.tn@gmail.com.
        command = RCPT TO
        response = 5.7.1 <hb_elec@gnet.tn>: Sender address rejected: not logged in

    terminate called after throwing an instance of 'vmime::exceptions::command_error'
      what():  Error while executing command 'RCPT TO': slim.it.tn@gmail.com.
    **

    and here is my code :

    vmime::messageBuilder mb;
            // Fill in some header fields and message body
            mb.setSubject(vmime::text("Message Subject"));
            mb.setExpeditor(vmime::mailbox("hb_elec@gnet.tn"));
            mb.getRecipients().appendAddress(vmime::create<vmime::mailbox>(vmime::string("slim.it.tn@gmail.com")));
            mb.getTextPart()->setCharset(vmime::charsets::UTF_8);
            mb.getTextPart()->setText(vmime::create<vmime::stringContentHandler>("This is the text of your message..."));
            // Message construction
            vmime::ref <vmime::message> msg = mb.construct();
            // Create a new session
            vmime::utility::url url("smtp://hbelec:hb2154@smtp.gnet.tn");
            vmime::ref <vmime::net::session> sess = vmime::create<vmime::net::session>();
            // Create an instance of the transport service
            vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
            // Connect it
            tr->connect();
            //Send the message
            tr->send(msg);
            // We have finished using the service
            tr->disconnect();
    
     
  • Bhiri Slim

    Bhiri Slim - 2011-01-22

    I don't understand why i'm not logged in.

    The correct hostname is : smtp.gnet.tn
    authentification is activate(clear) :
    login: hb2154
    password: hb2154

    sender address is : hb_elec@gnet.tn.

    i tried to send with evolution using this informations and it succeeds to send.

    Thanks.

    slimittn.

     
  • Bhiri Slim

    Bhiri Slim - 2011-01-22

    sorry,

    login: hbelec

     
  • Vincent Richard

    Vincent Richard - 2011-01-30

    Hello,

    Try this:
    tr->setProperty("options.need-authentication", true);

    before calling tr->connect().

    Regards,

    Vincent

     
  • Bhiri Slim

    Bhiri Slim - 2011-02-02

    Hi,

    i have also tried this as in the vmime book.

    Vincent,

    je suis entrain de développer une application propriétaire et si tout marche bien je compte acheter vMime. Mais le problème est que ça marche sur linux mais pas sur windows. Trop de problème de compilation.

     
  • TuanNN

    TuanNN - 2013-12-05

    I have same error when connecting to gmail, this i my code:

    vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();
    vmime::utility::url url("imaps://[user]:[pass]@imap.gmail.com:993");
    vmime::ref<vmime::net::session> session(vmime::create<vmime::net::session>());
    vmime::ref <vmime::net::store> store = session->getStore(url);
    store->setProperty("options.need-authentication", true);
    printf("connecting..\n");
    store->connect();

    but terminal show: terminate called after throwing an instance of 'vmime::exceptions::certificate_verification_exception'
    what(): Cannot verify certificate against trusted certificates.
    Aborted (core dumped)
    What wrong in here?

     

    Last edit: TuanNN 2013-12-05

Log in to post a comment.