Click here to Skip to main content
16,020,249 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Is this possible to send a mail if SMTP USERNAME & FROM ADDRESSES are different ?

For example ;

C#
message.From = new MailAddress("bbbb@mydomain.com");
            message.To.Add(new MailAddress(to));
            message.CC.Add(new MailAddress(cc));
            message.Bcc.Add(new MailAddress(bcc));
            message.Subject = subject;
            message.Body = body;
            message.IsBodyHtml = true;
            
            SmtpClient mailClient = new SmtpClient("mydomain");
            mailClient.EnableSsl = true;
            mailClient.Port = Convert.ToInt32(objSettings.Port);
            mailClient.UseDefaultCredentials = true;
            mailClient.Credentials = new NetworkCredential("aaaa@mydomain.com", "password");



Here i specified from address as "bbbb@mydomain.com" and smtp username is "aaaa@mydomain.com". But I'm getting mail from "aaaa@mydomain.com" even though I was set "From" address as "bbbb@mydomain.com".

How will I get mail from my "From" (custom address , will change dynamically) address with diff smtp username ?

Please Reply,
Posted
Updated 3-Jan-12 19:01pm
v2

Of course this is possible, as "From" address has nothing to do with your authentication with SMTP server.
Please see this code sample: http://codesnippets.joyent.com/posts/show/1362[^].
Moreover, formally, it does not matter where you are "getting mail". This is a different service which can be implemented by the same software but can have different URL, authentication; and a different protocol is used (what is it in your case — POP3? — does not really matter…).


—SA
 
Share this answer
 
From Address can be changed if i have authenticated it in my mail account
Ex.
If i have configured my gmail account from settings of account for different 'from ID' in that case it can be change..
 
Share this answer
 

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