Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Developing U++ » UppHub » WebMail package (POP/SMPT/IMAP)
Re: WebMail package (POP/SMPT/IMAP) [message #20844 is a reply to message #20841] Mon, 13 April 2009 23:57 Go to previous messageGo to previous message
Oblivion is currently offline  Oblivion
Messages: 1215
Registered: August 2007
Senior Contributor
Quote:


What about smtp? I'll need to send a simple mail with one or two files. So I'm thinking about the more simple and fast variants. Can you help me with a simple code-snippet or advice?

It will be great, if you could show a "conversation" with the socket, it will help to realize how to send a mail with attachments successfully. And I don't know much more about MIME format, and about free tools for it, >_<.

And I'm going to search the answers myself too, yeh, of cause.

Best regards, great man, and sorry for my English,
Anton.



Hello Anton,

Actually, the code of this "yet-to-be-finished" (I'm sorry, I'm way too busy nowadays... I didn't have the time to finish it) class is based upon the original U++ SmtpMail class. So you should check "SMTPMail::Send()" method in Web/smtp.h. It will give you an idea about the socket "transaction" (or conversation, if you will). It works almost like my unfinished POP3Mail class.

Smtp example code should be something like this:

#ifndef _SmtpExample_SmtpExample_h
#define _SmtpExample_SmtpExample_h

#include <CtrlLib/CtrlLib.h>
#include <Web/Web.h>
using namespace Upp;

#define LAYOUTFILE <SmtpExample/SmtpExample.lay>
#include <CtrlCore/lay.h>

class SmtpExample : public WithSmtpExampleLayout<TopWindow> {
public:
	typedef SmtpExample CLASSNAME;
	SmtpExample();
	
	SmtpMail smtp;
	
	void	Send();
};

SmtpExample::SmtpExample()
{
	CtrlLayout(*this, "Smtp Example");
	
	smtp.Transcript();
	smtp.Subject("Smtp Example");
	smtp.Port(25);
	smtp.Host("smtp.host.com");
	smtp.Auth("username", "password");
	smtp.From("from");
	smtp.To("to");
	smtp.AttachFile("filename", mimetype = 0);
	SendButton << THISBACK(Send); 

}

void SmtpExample::Send()
{
	smtp.Send();
	LogConsole.Set(smtp.GetTranscript());
}


GUI_APP_MAIN
{
	SmtpExample().Run();
}


But beware, this code probably won't work; because most of the servers require at least a TLS encryption/session after the first "HELO" message.

For more information on SMTP protocol you should read RFC 821 and RFC 5321.

You can read and search POP3/SMTP/MIME/TLS/SLL etc. RFC documents at:

http://www.rfc-editor.org/rfcsearch.html

I hope that this will give you an idea on where to start.

Regards.

Oblivion


[Updated on: Tue, 14 April 2009 00:01]

Report message to a moderator

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: SCGI Server Class
Next Topic: Docking - Strange behaviour with GlCtrl
Goto Forum:
  


Current Time: Sun Jul 20 14:19:08 CEST 2025

Total time taken to generate the page: 0.03862 seconds