2016-06-22 3 views
1

사용자가 응용 프로그램을 작성하는 각도의 양식 핸들이 있습니다. 그것은 잘 작동 ,이 같은 전자 메일을 보내 드릴 API를 사용Angular와 Mandrill을 사용하여 전자 메일을 통해 양식 결과를 보내십시오.

var m = new mandrill.Mandrill('your_api_key'); // This will be public 

function sendTheMail(){ 
    m.messages.send({ 
     "message": { 
      "from_email": "your_email_address", 
      "from_name": "your_name", 
      "to":[{"email": "someone's_email_address", "name": "someone's_name"}], // Array of recipients 
      "subject": "optional_subject_line", 
      "text": "Text to be sent in the body" // Alternatively, use the "html" key to send HTML emails rather than plaintext 
     } 
    }); 
} 

지금은 자신의 응용 프로그램에 PDF 첨부 파일을 추가 할 수 있도록하고 싶습니다. 형식을 PDF로 제한 할 수 있으며 크기는 비교적 작습니다.

가장 간단한 방법은 무엇입니까? https://github.com/nervgh/angular-file-upload과 같은 모듈을 추가해야합니까? 귀하의 메시지 JSON에 첨부

많은 감사

+0

맨드릴은'base64' 첨부 파일을 지원하므로 파일을'base64 '로 인코딩하고 첨부하면 최대 25MB 만 지원합니다. http://stackoverflow.com/questions/23025414/attach-files-to-mandrill-message-with-browse-button –

답변

0

메이크업 항목은, 당신이 더 첨부 파일을 추가 할 수있는 배열입니다. 첨부 파일 해시의 필드는 "type"(string) => 첨부 파일의 MIME 유형, "name"(string) => 첨부 파일의 파일 이름, "content"(string) => 첨부 파일의 내용 base64로 인코딩 된 문자열.

"attachments": [ 
     { 
      "type": "text/plain", 
      "name": "myfile.txt", 
      "content": "ZXhhbXBsZSBmaWxl" 
     } 
    ] 
관련 문제