{"record":{"id":"a773038f5fd95ea6","repo":"jstedfast/MailKit","slug":"no-sender-has-been-specified","errorCode":null,"errorMessage":"No sender has been specified.","messagePattern":"No sender has been specified\\.","errorType":"validation","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Smtp/SmtpClient.cs","lineNumber":2520,"sourceCode":"\t\t\t\toperation.SetError (ex);\n\n\t\t\t\tDisconnect (uri.Host, uri.Port, GetSecureSocketOptions (uri), false);\n\t\t\t\tthrow;\n\t\t\t}\n\t\t}\n\n\t\tstatic void ValidateArguments (FormatOptions options, MimeMessage message, out MailboxAddress sender, out IList<MailboxAddress> recipients)\n\t\t{\n\t\t\tif (options == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (options));\n\n\t\t\tif (message == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (message));\n\n\t\t\tvar mailbox = GetMessageSender (message);\n\n\t\t\tif (mailbox == null)\n\t\t\t\tthrow new InvalidOperationException (\"No sender has been specified.\");\n\n\t\t\tsender = mailbox;\n\t\t\trecipients = GetMessageRecipients (message);\n\n\t\t\tif (recipients.Count == 0)\n\t\t\t\tthrow new InvalidOperationException (\"No recipients have been specified.\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Send the specified message.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// <para>Sends the specified message.</para>\n\t\t/// <para>The sender address is determined by checking the following\n\t\t/// message headers (in order of precedence): Resent-Sender,\n\t\t/// Resent-From, Sender, and From.</para>\n\t\t/// <para>If either the Resent-Sender or Resent-From addresses are present,\n\t\t/// the recipients are collected from the Resent-To, Resent-Cc, and","sourceCodeStart":2502,"sourceCodeEnd":2538,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Smtp/SmtpClient.cs#L2502-L2538","documentation":"Validation in SmtpClient.ValidateArguments (shared by Send/SendAsync): the MimeMessage has no sender — neither a Resent-Sender/Sender header nor a From address could be resolved via GetMessageSender. SMTP requires a sender for the MAIL FROM command, so InvalidOperationException is thrown.","triggerScenarios":"MimeMessage without From/Sender passed to Send(message).","commonSituations":"Templates missing From header.","solutions":["Set message.From before send.","Use explicit-sender overload."],"exampleFix":"null","handlingStrategy":"validation","validationCode":"if (message.Sender == null && !message.From.Mailboxes.Any())\n\tthrow new InvalidOperationException(\"missing From\");","typeGuard":"bool HasSender(MimeMessage m) => m.Sender != null || m.From?.Mailboxes.Any() == true;","tryCatchPattern":"catch (InvalidOperationException ex) when (ex.Message == \"No sender has been specified.\") { /* set From and retry */ }","preventionTips":["Set message.From when constructing the message."],"tags":["smtp","mailkit","missing-sender"],"backgroundTag":"missing-required-argument","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}