Cause: When you are going to send mail in asp.net 1.1 by using google smtp server.then generally following error come.
Error:"The server rejected the sender address. The server response was: 530
5.7.0 Must issue a STARTTLS command first. f42sm2050000rvb.9"
Solution: Basically problem is SSL and Port. you need to set smtpusessl true and smtpserverport is 465.
C# Code:
MailMessage mail = new MailMessage();
mail.From = "fromjai@gmail.com"; // put the from address here
mail.To = "tojai@domain.com"; // put to address here
mail.Subject = "Test"; // put subject here
mail.Body = "Testing 12345 "; // put body of email here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1"); //basic authentication
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2"); //port to launch send
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "reporting@domain.com"); //set your username here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", "yourpassword"); //set your password here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "465"); //set your port here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", "smtp.gmail.com"); //set your password here
mail.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpusessl", true); //set SSL option to true
// send the mail
SmtpMail.Send(mail);
hope this help.
6 comments:
Thanks, The Above Code helped me a lot for when i am using System.web.Mail name space So i need Now For System.NET>Mail
Great
Awesome work.. Thanks
You have made some really good points there. I looked on the web for additional information about the issue and found
most people will go along with your views on this web site.
Here is my webpage Breast Actives Actually
Thanks a lot......
This code really works!!!!!!
I using own mail server but while runing the code in same file it doesnt shows error added the below mentioned in different class file
private void MailSend_prop(string msg, string toAddress, string psubject)
{
try
{
System.Web.Mail.MailMessage msg1 = new System.Web.Mail.MailMessage();
msg1.From = ConfigurationManager.AppSettings["MailFromAdd"].ToString();
msg1.To = toAddress;
msg1.Subject = psubject;
msg1.Priority = System.Web.Mail.MailPriority.High;
msg1.BodyFormat = System.Web.Mail.MailFormat.Html;
string bodystring = string.Empty;
bodystring += msg;
msg1.Body = bodystring;
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusing", "2");
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserver", ConfigurationManager.AppSettings["MailServer"].ToString());
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpserverport", "25");
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", msg1.From);
msg1.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword", ConfigurationManager.AppSettings["MailFromAddPwd"].ToString());
System.Web.Mail.SmtpMail.SmtpServer = ConfigurationManager.AppSettings["MailServer"].ToString();
System.Web.Mail.SmtpMail.Send(msg1);
}
catch (Exception ex)
{
throw ex;
}
}
Post a Comment