Click here to Skip to main content
15,879,613 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Guys

I am just wondering why google smtp is not using my from mail address instead it was pointing to the smtp email that i used.
C#
MailMessage mail = new MailMessage();
mail.To.Add("ToOther@gmail.com");
mail.From = new MailAddress("testfrom@gmail.com");
mail.Subject = "subj";

mail.Body = "Hi, this mail is to test sending mail using Gmail in ASP.NET";

mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
     ("jxxxxx@gmail.com", "Yzzzzzz");

smtp.EnableSsl = true;
smtp.Send(mail);

what appears from ToOther@gmail.com email sender is jxxxxx@gmail.com instead of testfrom@gmail.com

regards
Posted
Updated 13-Aug-12 14:13pm
v3
Comments
Kenneth Haugland 13-Aug-12 6:47am    
It seems to work exactly as specified... I dont understand your question, you send the e-mail from your gmail account so...
Andrei Straut 13-Aug-12 7:43am    
Is it just me, or does this look a bit like an email spoof attempt?

I mean, you do login with the network credentials (meaning that the account you are logging in is "jxxxxxx@gmail.com"), but you are trying to set the "From" flag to look like a different email address ("testfrom@gmail.com")

Have you tried setting it to look like a firstname/lastname? Maybe Google won't allow you because it thinks you are trying to spoof too.
EddyGuzman 13-Aug-12 13:23pm    
You can't do that with gmail
pradiprenushe 14-Aug-12 3:09am    
You have to purchase domain from gmail & then create two id in your domain then you can do this with your two id.

1 solution

Sounds like it's smart enough to stop you from doing what you want to do. Part of 'do no evil', I guess.
 
Share this answer
 
Comments
Mico Perez 13-Aug-12 20:15pm    
Not sure but there will always be solution.
Christian Graus 16-Aug-12 13:34pm    
Actually, no. Computers are not magic, and it's not magically possible to do whatever you like, esp when you use some one else's APIs.

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