Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
Hello everyone,

I m developing a website for Email Marketing.
User can register on my site by his/her any
existing(gmail,yahoo,etc.) email id.

While sending mail.I want my User's id to be
displayed in from field.

i.e.
mail.From = new MailAddress("UsersRegisteredEmailID");


while mail should be send my email id and my domain.
It is possibe ???

My Code:


MailMessage mail = new MailMessage();
        mail.From = new MailAddress(Users_Email_Address);
        mail.Subject = Subject;
        string content = Content;
       
        SmtpClient client = new SmtpClient();
        client.Credentials = new System.Net.NetworkCredential(MyEmail-Id,MyPass);
        client.Port = 587;
        string p = HttpContext.Current.Request.UserHostAddress;
        client.Host = "smtp.Mydomain.com";
        client.DeliveryMethod = SmtpDeliveryMethod.Network;
        AlternateView av1 = AlternateView.CreateAlternateViewFromString(content, null,MediaTypeNames.Text.Html );
       
         mail.AlternateViews.Add(av1);
        mail.IsBodyHtml = true;
        mail.To.Add(To_Address);
        client.Send(mail);


Pls Help...

Thanks
Posted

No. It will not work. To "send of behalf" of another email domain is many places considered spam.

Sender Policy Framework (SPF)[^]

Authenticate email with a domain key[^]

Best way, is to use your own email from addresse, and add user as BCC.
 
Share this answer
 
Comments
Sandeep Mewara 29-Apr-11 8:22am    
My 5!
Kim Togo 29-Apr-11 8:23am    
Thanks :-)
Kim Togo - Thanks for your Reply...But what I want is already done on several sites.
 
Share this answer
 
v2
Comments
Kim Togo 29-Apr-11 8:26am    
Yes perhaps. It is therefore SPF, DKIM and SenderID is invented.
If you use this on my email domain, then your service will fail. I will never received any email via this service.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900