I must send different emails... Every email has a aits own sender.. I want to connect to my smtp server just with one account..
So, for example I want to connect to the smtp server with this user: smtpclient@something.com
But I want to send the email from noreply@something.com
I wrote some code that send the email.. the code works because I receive the email.. but something goes wrong: I receive the email from smtpclient@something.com but I would like to receive the email from noreply@something.com
I am using EmailDefinition:
MailDefinition mailDefinition = new MailDefinition();
mailDefinition.BodyFileName = urlEmailLayout;
mailDefinition.IsBodyHtml = true;
mailDefinition.From = from.EmailAddress;
MailMessage email = mailDefinition.CreateMailMessage(string.Join(",", to.Select(t => t.EmailAddress)), bodyValues, new System.Web.UI.LiteralControl());
email.From = new MailAddress(from.EmailAddress, from.DisplayName);
And to send the email I use SmtpClient:
SmtpClient client = new SmtpClient(smtpServer.Host, smtpServer.Port);
client.EnableSsl = smtpServer.RequireCredential;
if(smtpServer.RequireCredential)
client.Credentials =
new System.Net.NetworkCredential(
smtpServer.Credential.Username,
smtpServer.Credential.Password
);
client.Send(this._email);
How can I do?
Thanx