EmailSender.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /*
  2. * Copyright (c) 2014, Oculus VR, Inc.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree. An additional grant
  7. * of patent rights can be found in the PATENTS file in the same directory.
  8. *
  9. */
  10. /// \file EmailSender.h
  11. /// \brief Rudimentary class to send email from code. Don't expect anything fancy.
  12. ///
  13. #include "NativeFeatureIncludes.h"
  14. #if _RAKNET_SUPPORT_EmailSender==1 && _RAKNET_SUPPORT_TCPInterface==1 && _RAKNET_SUPPORT_FileOperations==1
  15. #ifndef __EMAIL_SENDER_H
  16. #define __EMAIL_SENDER_H
  17. #include "RakNetTypes.h"
  18. #include "RakMemoryOverride.h"
  19. #include "Export.h"
  20. #include "Rand.h"
  21. #include "TCPInterface.h"
  22. namespace RakNet
  23. {
  24. /// Forward declarations
  25. class FileList;
  26. class TCPInterface;
  27. /// \brief Rudimentary class to send email from code.
  28. class RAK_DLL_EXPORT EmailSender
  29. {
  30. public:
  31. // GetInstance() and DestroyInstance(instance*)
  32. STATIC_FACTORY_DECLARATIONS(EmailSender)
  33. /// \brief Sends an email.
  34. /// \param[in] hostAddress The address of the email server.
  35. /// \param[in] hostPort The port of the email server (usually 25)
  36. /// \param[in] sender The email address you are sending from.
  37. /// \param[in] recipient The email address you are sending to.
  38. /// \param[in] senderName The email address you claim to be sending from
  39. /// \param[in] recipientName The email address you claim to be sending to
  40. /// \param[in] subject Email subject
  41. /// \param[in] body Email body
  42. /// \param[in] attachedFiles List of files to attach to the email. (Can be 0 to send none).
  43. /// \param[in] doPrintf true to output SMTP info to console(for debugging?)
  44. /// \param[in] password Used if the server uses AUTHENTICATE PLAIN over TLS (such as gmail)
  45. /// \return 0 on success, otherwise a string indicating the error message
  46. const char *Send(const char *hostAddress, unsigned short hostPort, const char *sender, const char *recipient, const char *senderName, const char *recipientName, const char *subject, const char *body, FileList *attachedFiles, bool doPrintf, const char *password);
  47. protected:
  48. const char *GetResponse(TCPInterface *tcpInterface, const SystemAddress &emailServer, bool doPrintf);
  49. RakNetRandom rakNetRandom;
  50. };
  51. } // namespace RakNet
  52. #endif
  53. #endif // _RAKNET_SUPPORT_*
粤ICP备19079148号