- if (!newuseremail_ok) {
- cprintf("%d You don't have permission to author messages as '%s'.\n",
- ERROR + HIGHER_ACCESS_REQUIRED,
- newuseremail
- );
- return;
- }
-
- CCC->cs_flags |= CS_POSTING;
-
- /* In mailbox rooms we have to behave a little differently --
- * make sure the user has specified at least one recipient. Then
- * validate the recipient(s). We do this for the Mail> room, as
- * well as any room which has the "Mailbox" view set - unless it
- * is the DRAFTS room which does not require recipients
- */
-
- if ( ( ( (CCC->room.QRflags & QR_MAILBOX) && (!strcasecmp(&CCC->room.QRname[11], MAILROOM)) )
- || ( (CCC->room.QRflags & QR_MAILBOX) && (CCC->curr_view == VIEW_MAILBOX) )
- ) && (strcasecmp(&CCC->room.QRname[11], USERDRAFTROOM)) !=0 ) {
- if (CCC->user.axlevel < AxProbU) {
- strcpy(recp, "sysop");
- strcpy(cc, "");
- strcpy(bcc, "");
- }
-
- valid_to = validate_recipients(recp, NULL, 0);
- if (valid_to->num_error > 0) {
- cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_to->errormsg);
- free_recipients(valid_to);
- return;
- }
-
- valid_cc = validate_recipients(cc, NULL, 0);
- if (valid_cc->num_error > 0) {
- cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_cc->errormsg);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- return;
- }
-
- valid_bcc = validate_recipients(bcc, NULL, 0);
- if (valid_bcc->num_error > 0) {
- cprintf("%d %s\n", ERROR + NO_SUCH_USER, valid_bcc->errormsg);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- return;
- }
-
- /* Recipient required, but none were specified */
- if ( (valid_to->num_error < 0) && (valid_cc->num_error < 0) && (valid_bcc->num_error < 0) ) {
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- cprintf("%d At least one recipient is required.\n", ERROR + NO_SUCH_USER);
- return;
- }
-
- if (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0) {
- if (CtdlCheckInternetMailPermission(&CCC->user)==0) {
- cprintf("%d You do not have permission "
- "to send Internet mail.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- return;
- }
- }
-
- if ( ( (valid_to->num_internet + valid_to->num_ignet + valid_cc->num_internet + valid_cc->num_ignet + valid_bcc->num_internet + valid_bcc->num_ignet) > 0)
- && (CCC->user.axlevel < AxNetU) ) {
- cprintf("%d Higher access required for network mail.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- return;
- }
-
- if ((RESTRICT_INTERNET == 1)
- && (valid_to->num_internet + valid_cc->num_internet + valid_bcc->num_internet > 0)
- && ((CCC->user.flags & US_INTERNET) == 0)
- && (!CCC->internal_pgm)) {
- cprintf("%d You don't have access to Internet mail.\n",
- ERROR + HIGHER_ACCESS_REQUIRED);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- return;
- }
-
- }
-
- /* Is this a room which has anonymous-only or anonymous-option? */
- anonymous = MES_NORMAL;
- if (CCC->room.QRflags & QR_ANONONLY) {
- anonymous = MES_ANONONLY;
- }
- if (CCC->room.QRflags & QR_ANONOPT) {
- if (anon_flag == 1) { /* only if the user requested it */
- anonymous = MES_ANONOPT;
- }
- }
-
- if ((CCC->room.QRflags & QR_MAILBOX) == 0) {
- recp[0] = 0;
- }
-
- /* Recommend to the client that the use of a message subject is
- * strongly recommended in this room, if either the SUBJECTREQ flag
- * is set, or if there is one or more Internet email recipients.
- */
- if (CCC->room.QRflags2 & QR2_SUBJECTREQ) subject_required = 1;
- if ((valid_to) && (valid_to->num_internet > 0)) subject_required = 1;
- if ((valid_cc) && (valid_cc->num_internet > 0)) subject_required = 1;
- if ((valid_bcc) && (valid_bcc->num_internet > 0)) subject_required = 1;
-
- /* If we're only checking the validity of the request, return
- * success without creating the message.
- */
- if (post == 0) {
- cprintf("%d %s|%d\n", CIT_OK,
- ((valid_to != NULL) ? valid_to->display_recp : ""),
- subject_required);
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
- return;
- }
-
- /* We don't need these anymore because we'll do it differently below */
- free_recipients(valid_to);
- free_recipients(valid_cc);
- free_recipients(valid_bcc);
-
- /* Read in the message from the client. */
- if (do_confirm) {
- cprintf("%d send message\n", START_CHAT_MODE);
- } else {
- cprintf("%d send message\n", SEND_LISTING);
- }
-
- msg = CtdlMakeMessage(&CCC->user, recp, cc,
- CCC->room.QRname, anonymous, format_type,
- newusername, newuseremail, subject,
- ((!IsEmptyStr(supplied_euid)) ? supplied_euid : NULL),
- NULL, references);
-
- /* Put together one big recipients struct containing to/cc/bcc all in
- * one. This is for the envelope.
- */
- char *all_recps = malloc(SIZ * 3);
- strcpy(all_recps, recp);
- if (!IsEmptyStr(cc)) {
- if (!IsEmptyStr(all_recps)) {
- strcat(all_recps, ",");
- }
- strcat(all_recps, cc);
- }
- if (!IsEmptyStr(bcc)) {
- if (!IsEmptyStr(all_recps)) {
- strcat(all_recps, ",");
- }
- strcat(all_recps, bcc);
- }
- if (!IsEmptyStr(all_recps)) {
- valid = validate_recipients(all_recps, NULL, 0);
- }
- else {
- valid = NULL;
- }
- free(all_recps);
-
- if ((valid != NULL) && (valid->num_room == 1))
- {
- /* posting into an ML room? set the envelope from
- * to the actual mail address so others get a valid
- * reply-to-header.
- */
- msg->cm_fields[eenVelopeTo] = strdup(valid->recp_orgroom);
- }
-
- if (msg != NULL) {
- msgnum = CtdlSubmitMsg(msg, valid, "", QP_EADDR);
- if (do_confirm) {
- cprintf("%ld\n", msgnum);
-
- if (StrLength(CCC->StatusMessage) > 0) {
- cprintf("%s\n", ChrPtr(CCC->StatusMessage));
- }
- else if (msgnum >= 0L) {
- client_write(HKEY("Message accepted.\n"));
- }
- else {
- client_write(HKEY("Internal error.\n"));
- }
-
- if (!CM_IsEmpty(msg, eExclusiveID)) {
- cprintf("%s\n", msg->cm_fields[eExclusiveID]);
- } else {
- cprintf("\n");
- }
- cprintf("000\n");
- }
-
- CM_Free(msg);
- }
- if (valid != NULL) {
- free_recipients(valid);
- }
- return;