ÃÑ ÆäÀÌÁö ¼ö : 3224

Àüü ÇÔ¼ö/¿ë¾î»çÀü
Facebook Joinc ±×·ì   Joinc QA »çÀÌÆ®
ÇöÀçÀ§Ä¡ : Code>C++>Mail



joinc´Â Firefox¿Í chrome¿¡¼­ Å×½ºÆ® Çß½À´Ï´Ù. IE¿¡¼­´Â Å×À̺íÀÌ ±úÁö°Å³ª À̹ÌÁö°¡ º¸ÀÌÁö ¾ÊÀ» ¼ö ÀÖ½À´Ï´Ù. ƯÈ÷ ±¸±Û DocsÀ̹ÌÁöÀÇ °æ¿ì ¿¢¹Úó¸®µÉ ¼ö ÀÖ½À´Ï´Ù.

  1. Mail
  2. ¸ÞÀÏ Àü¼ÛÇÔ¼ö
  3. yundream
  4. Version 0.2
  5. 2004/07/10


¼³¸í

sendmailÀ» ÀÌ¿ëÇÑ °£´ÜÇÑ ¸ÞÀÏ ¹ß¼Û ÇÁ·Î±×·¥, ¸Ç³¯ ÇÊ¿äÇÒ ¶§ ¸¶´Ù ÀçÀÛ¼º ÇÏ´Â°Ô Áö°Ü¿öÁ®¼­ ÇÊ¿äÇÒ¶§ ±Ü¾î ºÙÀÏ·Á°í ¸¸µé¾úÀ½.

»ç¿ë¹æ¹ý

#include "sendmail.h" 
 
int Mail::Send(char *mailer, char *email, char *header, char *body); 
 
  1. mailer : ¸ÞÀÏ Àü¼ÛÀ» À§ÇØ »ç¿ëÇÒ SMTP ÇÁ·Î±×·¥
  2. email : ¸ÞÀÏ ¹ÞÀ» À̸ÞÀÏ ÁÖ¼Ò
  3. header : »ç¿ëÀÚ Á¤ÀÇ Çì´õ
  4. body : ¸ÞÀÏ ³»¿ë

class Mail MyMail; 
 
char *header = "From: test_sender@joinc.co.kr\nSubject: ¾È³ç"; 
char *body = "hello world\nbanga"; 
 
MyMail.Send("sendmail -v", "test@joinc.co.kr", header, body); 
 

ÄÚµå


  • sendmail.h

    #ifndef _SENDMAIL_H_ 
    #define _SENDMAIL_H_ 
    #include <string.h> 
    #include <unistd.h> 
    #include <stdio.h> 
     
    using namespace std; 
     
    class Mail 
    { 
        private: 
            char sendmailcmd[256]; 
            FILE *mfp; 
     
        public: 
            Mail() 
            { 
                mfp = NULL; 
            } 
            ~Mail() 
            { 
            } 
            int Send(char *sender, char *addr ,char *header, char *body); 
    }; 
    #endif 
     
  • sendmail.cc

    #include "sendmail.h" 
    #include <iostream> 
     
    int Mail::Send(char *sender, char *addr, char *header, char *body) 
    { 
        snprintf(sendmailcmd, 255, "%s %s", sender, addr); 
     
        mfp = popen(sendmailcmd, "w"); 
        if (mfp == NULL) 
        { 
            perror("sendmail open error"); 
            return 0; 
        } 
     
        fputs(header, mfp); 
     
        fputs("\n\n", mfp); 
        fputs(body, mfp); 
        if (pclose(mfp) == -1) 
        { 
            cout << "send mail error\n" << endl; 
            return 1; 
        } 
        else 
            cout << "send mail ok\n" << endl; 
        return 1; 
    } 
     


º¯°æ»çÇ×

EmailÀ» ±âÀÔÇϸé, ´ñ±ÛÀÌ ¸ÞÀÏ·Î Àü´ÞµË´Ï´Ù.