| 512 | } |
| 513 | |
| 514 | void ServerPrivate::processNextMail() |
| 515 | { |
| 516 | while (!queue.isEmpty()) { |
| 517 | ServerReplyContainer &cont = queue[0]; |
| 518 | if (cont.reply.isNull()) { |
| 519 | queue.removeFirst(); |
| 520 | continue; |
| 521 | } |
| 522 | |
| 523 | if (cont.state == ServerReplyContainer::Initial) { |
| 524 | // Send the MAIL command with the sender |
| 525 | cont.commands << "MAIL FROM:<" + cont.msg.sender().address().toLatin1() + ">\r\n"; |
| 526 | cont.awaitedCodes << 250; |
| 527 | |
| 528 | // Send RCPT command for each recipient |
| 529 | // To (primary recipients) |
| 530 | const auto toRecipients = cont.msg.toRecipients(); |
| 531 | for (const EmailAddress &rcpt : toRecipients) { |
| 532 | cont.commands << "RCPT TO:<" + rcpt.address().toLatin1() + ">\r\n"; |
| 533 | cont.awaitedCodes << 250; |
| 534 | } |
| 535 | |
| 536 | // Cc (carbon copy) |
| 537 | const auto ccRecipients = cont.msg.ccRecipients(); |
| 538 | for (const EmailAddress &rcpt : ccRecipients) { |
| 539 | cont.commands << "RCPT TO:<" + rcpt.address().toLatin1() + ">\r\n"; |
| 540 | cont.awaitedCodes << 250; |
| 541 | } |
| 542 | |
| 543 | // Bcc (blind carbon copy) |
| 544 | const auto bccRecipients = cont.msg.bccRecipients(); |
| 545 | for (const EmailAddress &rcpt : bccRecipients) { |
| 546 | cont.commands << "RCPT TO:<" + rcpt.address().toLatin1() + ">\r\n"; |
| 547 | cont.awaitedCodes << 250; |
| 548 | } |
| 549 | |
| 550 | // DATA command |
| 551 | cont.commands << QByteArrayLiteral("DATA\r\n"); |
| 552 | cont.awaitedCodes << 354; |
| 553 | |
| 554 | qCDebug(SIMPLEMAIL_SERVER) |
| 555 | << "Sending MAIL command" << capPipelining << cont.commands.size() << cont.commands |
| 556 | << cont.awaitedCodes; |
| 557 | if (capPipelining) { |
| 558 | for (const QByteArray &cmd : qAsConst(cont.commands)) { |
| 559 | socket->write(cmd); |
| 560 | } |
| 561 | } else { |
| 562 | socket->write(cont.commands.first()); |
| 563 | } |
| 564 | |
| 565 | state = SendingMail; |
| 566 | cont.state = ServerReplyContainer::SendingCommands; |
| 567 | return; |
| 568 | } else { |
| 569 | return; |
| 570 | } |
| 571 | } |
no test coverage detected