Please read to the end to see what my proble is.
I have no problem sendig emails.
I'd like to add "Send to a friend" function to my website.
This function will get three things from the user:
1- His/her Name.
2- His/her Email address.(like email@example.com)
3- His/her friend Email address.(like myFriend@ddd.com)
Then I send an email to myFriend@ddd.com and add a text as the body of the email.
What I'd like to do is that I want to put firstname.lastname@example.org (user's email address) as the Sender of my email but It gives me the error. I have to set the Sender to an email from my website that I'v authenticate it in SMTP.
Some websites are doing it. For example www.BBC.com
, if you try to "send to a friend", it'll set your email address as the Sender of the email to your friend just like you logged in to your email and send an email to your friend!
Do you know how they can do it. And what is the way I can do it too.
Thanks in advance for your time and answers
MailMessage message = new MailMessage();
// message.From = new MailAddress("email@example.com"); // it's what I'd like to do but it give me an error, So I have to set the sender to an email from my website.
message.From = new MailAddress("firstname.lastname@example.org");
SmtpClient client = new SmtpClient();
message.Body = Mytext ;
message.Subject = "send to a friend";