Example #1
0
// static
shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const size_t size)
{
	std::ostringstream cmd;
	cmd.imbue(std::locale::classic());
	cmd << "MAIL FROM:<";

	if (utf8)
	{
		cmd << mbox.getEmail().toText().getConvertedText(vmime::charsets::UTF_8);
	}
	else
	{
		vmime::utility::outputStreamAdapter cmd2(cmd);
		mbox.getEmail().generate(cmd2);
	}

	cmd << ">";

	if (utf8)
		cmd << " SMTPUTF8";

	if (size != 0)
		cmd << " SIZE=" << size;

	return createCommand(cmd.str());
}
void sendmailTransport::send
	(const mailbox& expeditor, const mailboxList& recipients,
	 utility::inputStream& is, const utility::stream::size_type size,
         utility::progressListener* progress)
{
	// If no recipient/expeditor was found, throw an exception
	if (recipients.isEmpty())
		throw exceptions::no_recipient();
	else if (expeditor.isEmpty())
		throw exceptions::no_expeditor();

	// Construct the argument list
	std::vector <string> args;

	args.push_back("-i");
	args.push_back("-f");
	args.push_back(expeditor.getEmail());
	args.push_back("--");

	for (int i = 0 ; i < recipients.getMailboxCount() ; ++i)
		args.push_back(recipients.getMailboxAt(i)->getEmail());

	// Call sendmail
	try
	{
		internalSend(args, is, size, progress);
	}
	catch (vmime::exception& e)
	{
		throw exceptions::command_error("SEND", "", "sendmail failed", e);
	}
}
Example #3
0
// static
shared_ptr <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
{
	std::ostringstream cmd;
	cmd.imbue(std::locale::classic());
	cmd << "RCPT TO:<";

	if (utf8)
	{
		cmd << mbox.getEmail().toText().getConvertedText(vmime::charsets::UTF_8);
	}
	else
	{
		vmime::utility::outputStreamAdapter cmd2(cmd);
		mbox.getEmail().generate(cmd2);
	}

	cmd << ">";

	return createCommand(cmd.str());
}