PageRenderTime 37ms CodeModel.GetById 24ms 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
Possible License(s): LGPL-2.1
  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. #ifndef LL_LLMAIL_H
  27. #define LL_LLMAIL_H
  28. typedef struct apr_pool_t apr_pool_t;
  29. #include "llsd.h"
  30. class LLMail
  31. {
  32. public:
  33. // if hostname is NULL, then the host is resolved as 'mail'
  34. static void init(const std::string& hostname, apr_pool_t* pool);
  35. // Allow all email transmission to be disabled/enabled.
  36. static void enable(bool mail_enabled);
  37. /**
  38. * @brief send an email
  39. * @param from_name The name of the email sender
  40. * @param from_address The email address for the sender
  41. * @param to_name The name of the email recipient
  42. * @param to_address The email recipient address
  43. * @param subject The subject of the email
  44. * @param headers optional X-Foo headers in an llsd map.
  45. * @return Returns TRUE if the call succeeds, FALSE otherwise.
  46. *
  47. * Results in:
  48. * From: "from_name" <from_address>
  49. * To: "to_name" <to_address>
  50. * Subject: subject
  51. *
  52. * message
  53. */
  54. static BOOL send(
  55. const char* from_name,
  56. const char* from_address,
  57. const char* to_name,
  58. const char* to_address,
  59. const char* subject,
  60. const char* message,
  61. const LLSD& headers = LLSD());
  62. /**
  63. * @brief build the complete smtp transaction & header for use in an
  64. * mail.
  65. *
  66. * @param from_name The name of the email sender
  67. * @param from_address The email address for the sender
  68. * @param to_name The name of the email recipient
  69. * @param to_address The email recipient address
  70. * @param subject The subject of the email
  71. * @param headers optional X-Foo headers in an llsd map.
  72. * @return Returns the complete SMTP transaction mail header.
  73. */
  74. static std::string buildSMTPTransaction(
  75. const char* from_name,
  76. const char* from_address,
  77. const char* to_name,
  78. const char* to_address,
  79. const char* subject,
  80. const LLSD& headers = LLSD());
  81. /**
  82. * @brief send an email with header and body.
  83. *
  84. * @param header The email header. Use build_mail_header().
  85. * @param message The unescaped email message.
  86. * @param from_address Used for debugging
  87. * @param to_address Used for debugging
  88. * @return Returns true if the message could be sent.
  89. */
  90. static bool send(
  91. const std::string& header,
  92. const std::string& message,
  93. const char* from_address,
  94. const char* to_address);
  95. // IM-to-email sessions use a "session id" based on an encrypted
  96. // combination of from agent_id, to agent_id, and timestamp. When
  97. // a user replies to an email we use the from_id to determine the
  98. // sender's name and the to_id to route the message. The address
  99. // is encrypted to prevent users from building addresses to spoof
  100. // IMs from other users. The timestamps allow the "sessions" to
  101. // expire, in case one of the sessions is stolen/hijacked.
  102. //
  103. // indra/tools/mailglue is responsible for parsing the inbound mail.
  104. //
  105. // secret: binary blob passed to blowfish, max length 56 bytes
  106. // secret_size: length of blob, in bytes
  107. //
  108. // Returns: "base64" encoded email local-part, with _ and - as the
  109. // non-alphanumeric characters. This allows better compatibility
  110. // with email systems than the default / and + extra chars. JC
  111. static std::string encryptIMEmailAddress(
  112. const LLUUID& from_agent_id,
  113. const LLUUID& to_agent_id,
  114. U32 time,
  115. const U8* secret,
  116. size_t secret_size);
  117. };
  118. extern const size_t LL_MAX_KNOWN_GOOD_MAIL_SIZE;
  119. #endif