コード例 #1
0
ファイル: transport.cpp プロジェクト: 0xd34df00d/vmime
void transport::send
	(shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
	 utility::progressListener* progress, const mailbox& sender)
{
	// Generate the message, "stream" it and delegate the sending
	// to the generic send() function.
	std::ostringstream oss;
	utility::outputStreamAdapter ossAdapter(oss);

	msg->generate(ossAdapter);

	const string& str(oss.str());

	utility::inputStreamStringAdapter isAdapter(str);

	send(expeditor, recipients, isAdapter, str.length(), progress, sender);
}
コード例 #2
0
ファイル: transport.cpp プロジェクト: dezelin/maily
void transport::send(ref <vmime::message> msg, utility::progressListener* progress)
{
	// Extract expeditor
	mailbox expeditor;

	try
	{
		const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)->
			getValue().dynamicCast <const mailbox>();

		expeditor = mbox;
	}
	catch (exceptions::no_such_field&)
	{
		throw exceptions::no_expeditor();
	}

	// Extract recipients
	mailboxList recipients;

	try
	{
		const addressList& to = *msg->getHeader()->findField(fields::TO)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, to);
	}
	catch (exceptions::no_such_field&) { }

	try
	{
		const addressList& cc = *msg->getHeader()->findField(fields::CC)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, cc);
	}
	catch (exceptions::no_such_field&) { }

	try
	{
		const addressList& bcc = *msg->getHeader()->findField(fields::BCC)->
			getValue().dynamicCast <const addressList>();

		extractMailboxes(recipients, bcc);
	}
	catch (exceptions::no_such_field&) { }

	// Remove BCC headers from the message we're about to send, as required by the RFC.
	// Some SMTP server automatically strip this header (Postfix, qmail), and others
	// have an option for this (Exim).
	try
	{
		ref <headerField> bcc = msg->getHeader()->findField(fields::BCC);
		msg->getHeader()->removeField(bcc);
	}
	catch (exceptions::no_such_field&) { }

	// Generate the message, "stream" it and delegate the sending
	// to the generic send() function.
	std::ostringstream oss;
	utility::outputStreamAdapter ossAdapter(oss);

	msg->generate(ossAdapter);

	const string& str(oss.str());

	utility::inputStreamStringAdapter isAdapter(str);

	send(expeditor, recipients, isAdapter, str.length(), progress);
}