PageRenderTime 72ms CodeModel.GetById 63ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/llmessage/llmail.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 130 lines | 38 code | 11 blank | 81 comment | 0 complexity | acad66762dfd021ae2aac593ce90ec7f MD5 | raw file
  1/** 
  2 * @file llmail.h
  3 * @brief smtp helper functions.
  4 *
  5 * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6 * Second Life Viewer Source Code
  7 * Copyright (C) 2010, Linden Research, Inc.
  8 * 
  9 * This library is free software; you can redistribute it and/or
 10 * modify it under the terms of the GNU Lesser General Public
 11 * License as published by the Free Software Foundation;
 12 * version 2.1 of the License only.
 13 * 
 14 * This library is distributed in the hope that it will be useful,
 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 17 * Lesser General Public License for more details.
 18 * 
 19 * You should have received a copy of the GNU Lesser General Public
 20 * License along with this library; if not, write to the Free Software
 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 22 * 
 23 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
 24 * $/LicenseInfo$
 25 */
 26
 27#ifndef LL_LLMAIL_H
 28#define LL_LLMAIL_H
 29
 30typedef struct apr_pool_t apr_pool_t;
 31
 32#include "llsd.h"
 33
 34class LLMail
 35{
 36public:
 37	// if hostname is NULL, then the host is resolved as 'mail'
 38	static void init(const std::string& hostname, apr_pool_t* pool);
 39
 40	// Allow all email transmission to be disabled/enabled.
 41	static void enable(bool mail_enabled);
 42
 43	/**
 44	 * @brief send an email
 45	 * @param from_name The name of the email sender
 46	 * @param from_address The email address for the sender
 47	 * @param to_name The name of the email recipient
 48	 * @param to_address The email recipient address
 49	 * @param subject The subject of the email
 50	 * @param headers optional X-Foo headers in an llsd map. 
 51	 * @return Returns TRUE if the call succeeds, FALSE otherwise.
 52	 *
 53	 * Results in:
 54	 * From: "from_name" <from_address>
 55	 * To:   "to_name" <to_address>
 56	 * Subject: subject
 57	 * 
 58	 * message
 59	 */
 60	static BOOL send(
 61		const char* from_name,
 62		const char* from_address,
 63		const char* to_name,
 64		const char* to_address,
 65		const char* subject,
 66		const char* message,
 67		const LLSD& headers = LLSD());
 68
 69	/**
 70	 * @brief build the complete smtp transaction & header for use in an
 71	 * mail.
 72	 *
 73	 * @param from_name The name of the email sender
 74	 * @param from_address The email address for the sender
 75	 * @param to_name The name of the email recipient
 76	 * @param to_address The email recipient address
 77	 * @param subject The subject of the email
 78	 * @param headers optional X-Foo headers in an llsd map. 
 79	 * @return Returns the complete SMTP transaction mail header.
 80	 */
 81	static std::string buildSMTPTransaction(
 82		const char* from_name,
 83		const char* from_address,
 84		const char* to_name,
 85		const char* to_address,
 86		const char* subject,
 87		const LLSD& headers = LLSD());
 88
 89	/**
 90	* @brief send an email with header and body.
 91	*
 92	* @param header The email header. Use build_mail_header().
 93	* @param message The unescaped email message.
 94	* @param from_address Used for debugging
 95	* @param to_address Used for debugging
 96	* @return Returns true if the message could be sent.
 97	*/
 98	static bool send(
 99		const std::string& header,
100		const std::string& message,
101		const char* from_address,
102		const char* to_address);
103
104	// IM-to-email sessions use a "session id" based on an encrypted
105	// combination of from agent_id, to agent_id, and timestamp.  When
106	// a user replies to an email we use the from_id to determine the
107	// sender's name and the to_id to route the message.  The address
108	// is encrypted to prevent users from building addresses to spoof
109	// IMs from other users.  The timestamps allow the "sessions" to 
110	// expire, in case one of the sessions is stolen/hijacked.
111	//
112	// indra/tools/mailglue is responsible for parsing the inbound mail.
113	//
114	// secret: binary blob passed to blowfish, max length 56 bytes
115	// secret_size: length of blob, in bytes
116	//
117	// Returns: "base64" encoded email local-part, with _ and - as the
118	// non-alphanumeric characters.  This allows better compatibility
119	// with email systems than the default / and + extra chars.  JC
120	static std::string encryptIMEmailAddress(
121		const LLUUID& from_agent_id,
122		const LLUUID& to_agent_id,
123		U32 time,
124		const U8* secret,
125		size_t secret_size);
126};
127
128extern const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE;
129
130#endif