Hi,
I am sending the information I collected from my 'Contact Us' page to my email which is supported by google apps.
When I receive the email from the website I want to see the email id of the sender in FROM which was entered in txtEmail.Text.
m.From = new System.Net.Mail.MailAddress(txtEmail.Text, txtName.Text);
But this is not happening. When I receive the email in From, I am getting "[email protected]".
How can I correct it?
System.Net.NetworkCredential c = new System.Net.NetworkCredential();
c.Password = "my_Credential_Password";
c.UserName = "[email protected]";
System.Net.Mail.MailMessage m = new System.Net.Mail.MailMessage();
m.From = new System.Net.Mail.MailAddress(txtEmail.Text, txtName.Text);
m.To.Add("[email protected]");
m.Headers.Add("Reply-To", txtEmail.Text);
m.Subject = "My Website Enquiry: " + txtSubject.Text;
m.Body = txtBody.Text;
m.IsBodyHtml = false;
System.Net.Mail.SmtpClient s = new System.Net.Mail.SmtpClient();
s.UseDefaultCredentials = false;
s.Credentials = c;
s.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
s.EnableSsl = true;
s.Port = 587;
s.Host = "smtp.gmail.com";
s.Send(m);
Thanks,
r pPosted Aug 8, 2011, 7:49 AM
Even if I add an extra line -
m.Headers.Add("Sender", txtEmail.Text);
when I receive my email, in FROM I am getting - "[email protected]".
Still working on it!!
Thanks,
Sam HobbsPosted Aug 6, 2011, 11:38 AM
The SPF parameters are put into the domain registration of the "from" field; it is not specified in the server that is being used to send email. In other words, in this case, the relevant SPF parameters would not be in the Gmail server. I know I tried to use SPF for some of my email addresses by updating the domain registration for their domain.
Anything in SPF Best Practices that is relevant to Gmail should be stated in the documentation that Gmail provides of how to use Gmail and it would certainly be shown in sample code showing how to use Gmail.
Satish BhatPosted Aug 6, 2011, 3:18 AM
Three of my clients faced the same problem some times back. When I contacted the respective service providers, I got the same reply citing the SPF implementation.
They were right also. When one of the clients opted for the alternative provider who allowed the functionality and used it for e-mail communication between registered members, his domain was blocked by Spamhaus SBL. I had to work hard to remove the e-mail address from the SBL blacklist.
You are right in "Many SMTP servers do explicitly allow their servers to be used to send email for otehr domains". That is the core business logic of e-mail service providers.
But what I meant by "SMTP servers does not allow e-mails to be sent using their server from different e-mail addresses" was most of the service providers demand that you have to have a registered email address with them in the from field as per the Sender Policy Framework (SPF) Best Practices.
Please go through the SPF Best Practices for web-generated e-mailers.
It suggests,
"Choose a general address in your domain ([email protected]).
This is what happening in r p's case.
So r p can try adding Sender header and see the result.
m.Headers.Add("Sender", txtEmail.Text);
Sam HobbsPosted Aug 5, 2011, 6:18 PM
Have you looked at the articles in this web site? I think there is at least one about Gmail explicitly.
r pPosted Aug 5, 2011, 6:05 PM
Thanks
Sam HobbsPosted Aug 5, 2011, 5:25 PM
Satish BhatPosted Aug 5, 2011, 7:20 AM
"Note that if you choose to send mail from an alternate address through Gmail's servers, your Gmail address will still be included in your email header's sender field, to help prevent your mail from being marked as spam. Most email clients don't display the sender field, though some versions of Microsoft Outlook may display "From [email protected] on behalf of [email protected]."
Zoran HorvatPosted Aug 5, 2011, 7:07 AM
Zoran
Zoran HorvatPosted Aug 5, 2011, 7:02 AM
Zoran