- if (sock < 0) {
- *status = 4; /* dsn is already filled in */
- return;
- }
-
- CCC->sReadBuf = NewStrBuf();
- CCC->sMigrateBuf = NewStrBuf();
- CCC->sPos = NULL;
-
- /* Process the SMTP greeting from the server */
- if (ml_sock_gets(&sock, buf, 90) < 0) {
- *status = 4;
- strcpy(dsn, "Connection broken during SMTP conversation");
- goto bail;
- }
- syslog(LOG_DEBUG, "<%s", buf);
- if (buf[0] != '2') {
- if (buf[0] == '4') {
- *status = 4;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- else {
- *status = 5;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- }
-
- /* At this point we know we are talking to a real SMTP server */
-
- /* Do a EHLO command. If it fails, try the HELO command. */
- snprintf(buf, sizeof buf, "EHLO %s\r\n", config.c_fqdn);
- syslog(LOG_DEBUG, ">%s", buf);
- sock_write(&sock, buf, strlen(buf));
- if (ml_sock_gets(&sock, buf, 30) < 0) {
- *status = 4;
- strcpy(dsn, "Connection broken during SMTP HELO");
- goto bail;
- }
- syslog(LOG_DEBUG, "<%s", buf);
- if (buf[0] != '2') {
- snprintf(buf, sizeof buf, "HELO %s\r\n", config.c_fqdn);
- syslog(LOG_DEBUG, ">%s", buf);
- sock_write(&sock, buf, strlen(buf));
- if (ml_sock_gets(&sock, buf, 30) < 0) {
- *status = 4;
- strcpy(dsn, "Connection broken during SMTP HELO");
- goto bail;
- }
- }
- if (buf[0] != '2') {
- if (buf[0] == '4') {
- *status = 4;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- else {
- *status = 5;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- }
-
- /* Do an AUTH command if necessary */
- if (!IsEmptyStr(mx_user)) {
- char encoded[1024];
- sprintf(buf, "%s%c%s%c%s", mx_user, '\0', mx_user, '\0', mx_pass);
- CtdlEncodeBase64(encoded, buf, strlen(mx_user) + strlen(mx_user) + strlen(mx_pass) + 2, 0);
- snprintf(buf, sizeof buf, "AUTH PLAIN %s\r\n", encoded);
- syslog(LOG_DEBUG, ">%s", buf);
- sock_write(&sock, buf, strlen(buf));
- if (ml_sock_gets(&sock, buf, 30) < 0) {
- *status = 4;
- strcpy(dsn, "Connection broken during SMTP AUTH");
- goto bail;
- }
- syslog(LOG_DEBUG, "<%s", buf);
- if (buf[0] != '2') {
- if (buf[0] == '4') {
- *status = 4;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- else {
- *status = 5;
- safestrncpy(dsn, &buf[4], 1023);
- goto bail;
- }
- }
+ imsg = malloc(sizeof(struct CtdlMessage));
+ memset(imsg, 0, sizeof(struct CtdlMessage));
+ imsg->cm_magic = CTDLMESSAGE_MAGIC;
+ imsg->cm_anon_type = MES_NORMAL;
+ imsg->cm_format_type = FMT_RFC822;
+ CM_SetField(imsg, eMsgSubject, HKEY("QMSG"));
+ CM_SetField(imsg, eAuthor, HKEY("Citadel"));
+ CM_SetField(imsg, eJournal, HKEY("do not journal"));
+ CM_SetAsFieldSB(imsg, eMesageText, &SpoolMsg);
+ CtdlSubmitMsg(imsg, NULL, SMTP_SPOOLOUT_ROOM, QP_EADDR);
+ CM_Free(imsg);