Reputation: 7613
I am using Google SMTP for sending out emails from my app. The mails go out fine. But the from address is always set to the verification email. Is this by design?
SmtpClient smtpClient = new SmtpClient();
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = new System.Net.NetworkCredential("[email protected]", "mypwd");
smtpClient.EnableSsl = true;
MailMessage message = new MailMessage();
smtpClient.Host = "smtp.gmail.com";
smtpClient.Port = 587;
message.From = new MailAddress("[email protected]", "GuestName");
This last line should send the mail on behalf of the guest email.
Somehow I always see this is set to "[email protected]", not "[email protected]"
Is this by design or Google won't allow to set it that way?
How can I do what I said above?
Basically, my guest sends mail to a number of other people. I need my guest to know which emails has bounced.
Upvotes: 2
Views: 1493
Reputation: 29965
You have to verify the account you want to send mail from at gmail.com. You can find the setting at Settings -> Accounts and Import -> Send mail as.
Upvotes: 2