Russian Qt Forum
Май 23, 2024, 07:15 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.
Вам не пришло письмо с кодом активации?

Войти
 
  Начало   Форум  WIKI (Вики)FAQ Помощь Поиск Войти Регистрация  

Страниц: 1 [2]   Вниз
  Печать  
Автор Тема: mail  (Прочитано 12333 раз)
Авварон
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 3260


Просмотр профиля
« Ответ #15 : Июль 16, 2009, 16:43 »

сслыку на esmtp тоже видел:) беглым взглядом не увидел сильных отличий от мана, хотя в общем на сайте инфы больше... спасибо, буду разбираться:)
а jwsmtp отдельно качать\собирать из сорцов надо? бегло в репах не нашел
Записан
Alex Custov
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 2063


Просмотр профиля
« Ответ #16 : Июль 16, 2009, 16:49 »

сслыку на esmtp тоже видел:) беглым взглядом не увидел сильных отличий от мана, хотя в общем на сайте инфы больше... спасибо, буду разбираться:)
а jwsmtp отдельно качать\собирать из сорцов надо? бегло в репах не нашел

в репах нет, надо качать и собирать deb пакет. Если не компилится в Lenny, надо наложить патч.

Код
Diff
diff -ruN jwsmtp-1.32.13.orig/jwsmtp/demo2.cpp jwsmtp-1.32.13/jwsmtp/demo2.cpp
--- jwsmtp-1.32.13.orig/jwsmtp/demo2.cpp 2006-01-27 03:17:08.000000000 +0200
+++ jwsmtp-1.32.13/jwsmtp/demo2.cpp 2009-07-03 15:02:54.000000000 +0300
@@ -21,6 +21,7 @@
//#include <boost\thread\thread.hpp>
 
#include <iostream>
+#include <cstring>
#include "jwsmtp/jwsmtp.h"
 
using std::cout;
diff -ruN jwsmtp-1.32.13.orig/jwsmtp/jwsmtp/mailer.cpp jwsmtp-1.32.13/jwsmtp/jwsmtp/mailer.cpp
--- jwsmtp-1.32.13.orig/jwsmtp/jwsmtp/mailer.cpp 2006-07-04 19:51:32.000000000 +0300
+++ jwsmtp-1.32.13/jwsmtp/jwsmtp/mailer.cpp 2009-07-03 15:02:43.000000000 +0300
@@ -28,6 +28,8 @@
#include <sstream>   // ostrstream
#include <ctime>     // for localtime
#include <cassert>
+#include <cstring>
+#include <cstdlib>
#include "mailer.h"
#include "base64.h"
 

P.S. Почему стало нельзя делать аттачи?
Записан
Авварон
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 3260


Просмотр профиля
« Ответ #17 : Июль 17, 2009, 10:22 »

вот нашел пример юзания libesmtp. Код взят с китайского  сайта-_-, работоспособность не проверял...
Код:
#define _XOPEN_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
#include <getopt.h>
#include <string.h>
#include <fcntl.h>
#include <signal.h>
#include <errno.h>
#include <stdarg.h>

#include <libesmtp.h>

int main() {
    smtp_session_t session;
    smtp_message_t message;
    struct sigaction sa;
    const smtp_status_t *status;
    char buf[128];
    FILE *fp;
    /* This program sends only one message at a time.  Create an SMTP
       session and add a message to it. */
    if( (session = smtp_create_session ())  == NULL){
        fprintf (stderr, "smtp_create_session problem %s\n",
                smtp_strerror (smtp_errno (), buf, sizeof buf));
        return 1;
    }
    if((message = smtp_add_message (session)) == NULL){
        fprintf (stderr, "smtp_add_message problem %s\n",
                smtp_strerror (smtp_errno (), buf, sizeof buf));
        return 1;
    }
    /* NB.  libESMTP sets timeouts as it progresses through the protocol.
       In addition the remote server might close its socket on a timeout.
       Consequently libESMTP may sometimes try to write to a socket with
       no reader.  Ignore SIGPIPE, then the program doesn't get killed
       if/when this happens. */
    sa.sa_handler = SIG_IGN;
    sigemptyset (&sa.sa_mask);
    sa.sa_flags = 0;
    sigaction (SIGPIPE, &sa, NULL); 
    /* Set the host running the SMTP server.  LibESMTP has a default port
       number of 587, however this is not widely deployed so the port
       is specified as 25 along with the default MTA host. */
    smtp_set_server (session, "127.0.0.1:25");
    /* Set the reverse path for the mail envelope.  (NULL is ok)
     */
    smtp_set_reverse_path (message, "test@test.com");
    /* RFC 2822 doesn't require recipient headers but a To: header would
     *      be nice to have if not present. */
    smtp_set_header (message, "To", NULL, NULL);
    smtp_set_header (message, "Subject", " test mail");
    smtp_set_header_option (message, "Subject", Hdr_OVERRIDE, 1);
    fprintf(stderr,"%s\n","smtp_set_server.");
    if ((fp = fopen ("test-mail.eml", "r")) == NULL) {
        fprintf (stderr, "can't open mail file: %s\n", strerror (errno));
        return (1);
    }
    smtp_set_message_fp (message, fp);
    smtp_add_recipient (message,"test@localhost");
    /* Initiate a connection to the SMTP server and transfer the
       message. */
    if (!smtp_start_session (session)){
        fprintf (stderr, "SMTP server problem %s\n",
                smtp_strerror (smtp_errno (), buf, sizeof buf));
    }
    else{
        /* Report on the success or otherwise of the mail transfer.
        */
        status = smtp_message_transfer_status (message);
        printf ("%d %s", status->code,
                (status->text != NULL) ? status->text : "\n");
    }
    /* Free resources consumed by the program.
    */
    smtp_destroy_session (session);
    if(fp != NULL){
        fclose(fp);
    }

    return 0;
}
Записан
Авварон
Джедай : наставник для всех
*******
Offline Offline

Сообщений: 3260


Просмотр профиля
« Ответ #18 : Июль 20, 2009, 10:59 »

по поводу libesmtp - ни фига не работает:( Приходит пустое сообщение, хотя все теги заголовка прописываются правильно - нет только тела... причем странно нет - энтеры есть) возможно это косяк аутлука или exchange'а...
jwsmtp вроде работает:)
Записан
Страниц: 1 [2]   Вверх
  Печать  
 
Перейти в:  


Страница сгенерирована за 0.065 секунд. Запросов: 19.