Results 1 to 8 of 8

Thread: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

  1. #1
    Join Date
    Sep 2013
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    I need to send a HTML files to Mail
    i am using QTCPSocket ,
    i don t Know how to separate the Header and the Body content

    while i am sending without Header (from , to , subject), i can receive
    in HTML format

    when i add both and Header and content , i had received header correctly(from , to , subject) but ,
    i not getting the HTMlL format
    i am getting only in Text format

    so plz give me some tips
    thanks in advance

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    All emails are just text. You want to send a MIME encoded body to carry an HTML email body if you want the receiving mail reader to treat it as HTML.
    See RFC 2045 and RFC 2046.

  3. #3
    Join Date
    Sep 2013
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    thanks for your suggestion..Guru
    But
    I had tried that ,
    using that document only i had send a mail.
    when i set a content type as HTML and Header name .
    it also considering as Plain text
    hear i attached my coding only the body content


    Qt Code:
    1. Smtp::Smtp( const QString &from, const QString &to, const QString &subject , const QString &body ,const QString &address,int port)
    2. {
    3. socket = new QTcpSocket(this);
    4. connect( socket, SIGNAL(readyRead()), this, SLOT( readyRead() ) );
    5. connect( socket, SIGNAL( connected()), this, SLOT( connected() ) );
    6. connect(socket, SIGNAL(disconnected()), this,SLOT(disconnected()));
    7. message = "To: " + to + "\n";
    8. message.append("From: " + from + "\n");
    9. message.append("Subject: " + subject + "\n");
    10. //Let's intitiate multipart MIME with cutting boundary "frontier"
    11. message.append("MIME-Version: 1.0\n");
    12. message.append("Content-Type: multipart/mixed; boundary=frontier\n\n");
    13. message.append( "--frontier\n" );
    14. //message.append( "Content-Type: text/html\n\n" ); //Uncomment this for HTML
    15. formating, coment the line below
    16. message.append( "Content-Type: text/html\n\n" );
    17.  
    18. message.append(body);
    19.  
    20. message.append("\n\n");
    21. message.append( "--frontier--\n" );
    22.  
    23. message.replace( QString::fromLatin1( "\n" ), QString::fromLatin1( "\r\n" ) );
    24.  
    25. message.replace( QString::fromLatin1( "\r\n.\r\n" ),QString::fromLatin1( "\r\n..\r\n" ) );
    26.  
    27. this->from = from;
    28. rcpt = to;
    29. state = Init;
    30. socket->connectToHost( address,port);//"172.17.72.36", 25);
    31. t = new QTextStream( socket );
    32. if(socket->waitForConnected ( 30000 ))
    33. {qDebug("connected"); }
    34. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 4th September 2013 at 11:48. Reason: code tags

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    Oh dear, extreme multiposting, going to merge threads.

    Conflicting subjects too, but the postings seem to be the same.

  5. #5
    Join Date
    Sep 2013
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    sorry ,
    i not getting your answer
    so Plz elobrate it.
    give some correction in code
    where i need to change

    thanks in advance
    Last edited by $ATHEES; 4th September 2013 at 12:10. Reason: spelling corrections

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    In case you are referring to me, I didn't comment on the question itself, just merged the duplicated threads into one.
    You want all people to see all suggestions given so far, not a lot of duplicates all over the place.

    Cheers,
    _

  7. #7
    Join Date
    Sep 2013
    Posts
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    ok ...........thank you

  8. #8
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Receiving Mail only in the format of Plain Text Using QTcpSocket in SMTP

    Quote Originally Posted by $ATHEES View Post
    thanks for your suggestion..Guru
    But
    I had tried that ,
    Now, you see, that would have been useful information to have in your first post. It would be useful to know how the bytes are actually sent, what an example non-functioning message looks like (i.e. the actual complete, constructed message), what bytes are actually being received, what you are using to determine "i not getting the HTMlL format", what is 'it' in "it also considering as Plain text" etc.

    The boundary marker you have chosen is poor and could conceivably appear in the text of a part. Apart from that there is nothing that immediately jumps out as fundamentally broken with the code you posted. That code does not send, receive or interpret the received bytes though.

Similar Threads

  1. Sending mail Using Smtp Client
    By mohanakannan in forum Qt Programming
    Replies: 6
    Last Post: 5th July 2013, 11:47
  2. Replies: 9
    Last Post: 2nd March 2011, 12:58
  3. QTcpSocket slows down in receiving after several minutes
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2009, 22:14
  4. QTcpSocket + receiving data
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 2nd June 2009, 09:10
  5. sending encrypted data via mail using smtp
    By vermarajeev in forum General Programming
    Replies: 20
    Last Post: 14th August 2007, 20:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.