Feature Requests item #1873929

Add ability to include name in SMTP sender field
This commit is contained in:
Eran Hammer-Lahav 2008-01-17 16:49:03 +00:00
parent 3edd579220
commit 549d2751b1

View File

@ -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)
{