mirror of
https://github.com/pocoproject/poco.git
synced 2025-01-18 00:15:27 +01:00
Feature Requests item #1873929
Add ability to include name in SMTP sender field
This commit is contained in:
parent
3edd579220
commit
549d2751b1
@ -133,10 +133,20 @@ void SMTPClientSession::close()
|
||||
void SMTPClientSession::sendMessage(const MailMessage& message)
|
||||
{
|
||||
std::string response;
|
||||
std::string sender("<");
|
||||
sender.append(message.getSender());
|
||||
sender.append(">");
|
||||
int status = sendCommand("MAIL FROM:", sender, response);
|
||||
int status = 0;
|
||||
const std::string& fromField = message.getSender();
|
||||
std::string::size_type emailPos = fromField.find('<');
|
||||
if (emailPos == std::string::npos)
|
||||
{
|
||||
std::string sender("<");
|
||||
sender.append(fromField);
|
||||
sender.append(">");
|
||||
status = sendCommand("MAIL FROM:", sender, response);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = sendCommand("MAIL FROM:", fromField.substr(emailPos, fromField.size() - emailPos), response);
|
||||
}
|
||||
if (!isPositiveCompletion(status)) throw SMTPException("Cannot send message", response);
|
||||
for (MailMessage::Recipients::const_iterator it = message.recipients().begin(); it != message.recipients().end(); ++it)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user