Personal portfolio website for Regina Carvalho. Built with Famous.js library.

mandrill.js 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. angular.module('mandrill', [])
  2. .service('Mandrill', [ '$rootScope', '$http', function($rootScope, $http) {
  3. "use strict";
  4. this.sendMail = function(msgData) {
  5. var messagePost = {
  6. key: "m14Wkh0PhF74K2cTvxWPHA",
  7. message: {
  8. subject: msgData.name + " enviou uma mensagem",
  9. html: msgData.message,
  10. text: msgData.message,
  11. from_email: msgData.email,
  12. from_name: msgData.name,
  13. to: [
  14. {
  15. email: "james.peret@gmail.com",
  16. name: "James Peret",
  17. type: 'to'
  18. }
  19. ]
  20. }
  21. };
  22. console.log(messagePost);
  23. $http.post('https://mandrillapp.com/api/1.0/messages/send.json', { key: messagePost.key, message: messagePost.message })
  24. .success(function(data, status, headers, config){
  25. $rootScope.$broadcast('email_sent:success');
  26. console.log("> Message sent succesfully!");
  27. console.log(data);
  28. }).
  29. error(function(data, status, headers, config) {
  30. $rootScope.$broadcast('email_sent:error');
  31. console.log("> There was an error whule sending the Message.");
  32. console.log(data);
  33. });
  34. };
  35. }]);