Email not working,Not able to receive email for yahoo email id

你。 提交于 2019-12-23 05:25:22

问题


I am stuck and not able to receive email from yahoo id(if the sender email id is of yahoo). code is working fine not giving me any error and i am receiving email fromm gmail id. i am using localhost (not in local machine on live server). hosting server : smtp.snapgrid.com also used authentication,enable ssl , using proper port for ssl. on snapgrid i do check so i got is mail from yahoo is blocked and the message is,

message :

Type: blocked
Reason: 550 5.7.1 Unauthenticated email from yahoo.com is not accepted due to domain's    
DMARC policy. Please contact administrator of yahoo.com domain if this was a legitimate 
mail. Please visit http://support.google.com/mail/answer/2451690 to learn about DMARC 
initiative.

please help...

code i used to send is(its working fine just giving for idea):

Method 1:

     SmtpClient objSMTPClient = new SmtpClient();
            objSMTPClient.Host = ConfigurationManager.AppSettings["strSMTPServer"];
            string BODY_FORMAT = ConfigurationManager.AppSettings["EmailBodyContentFormat"];
            MailMessage objMailMessage = new MailMessage(from.Trim(), to.Trim(),   subject.Trim(), body.Trim());
            objSMTPClient.UseDefaultCredentials = false;
            if (BODY_FORMAT.ToUpper() == "HTML")
                objMailMessage.IsBodyHtml = true;

            else if (BODY_FORMAT.ToUpper() == "TEXT")
            {
                body = StripTags(body);
                objMailMessage.IsBodyHtml = false;

                objMailMessage.Body = body.ToString().Trim();
            }
            else
                return false;
            objSMTPClient.Send(objMailMessage);
            return true;

Method 2:

            SmtpClient oMail = new SmtpClient();
            MailMessage msg = new MailMessage();
            MailAddress Madd = new MailAddress(from, "sunil");
            oMail.Host = "smtp.gmail.com";
            oMail.Port = 587;
            oMail.EnableSsl = true;
            oMail.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
            oMail.Credentials = new NetworkCredential("sunil123@mydomain.com", "******");
            oMail.Timeout = 20000;
            msg.From = Madd;
            msg.Body = body.ToString();
            msg.To.Add(to);
            msg.Subject = subject;
            msg.IsBodyHtml = true;

            oMail.Send(msg);


            return true;

both are working having no bug running without error....


回答1:


If you are sending via a server belonging to someone like Yahoo, Google or Office365 they expect the sender name of the account to match that that you're sending using in the from address.

For example, this would work on a your local SMTP server:

Message.From = new MailAddress("GrandMasterFlush@domain.com"); 

However, to get it to send via someone like Yahoo would require you to send it like this:

Message.From = new MailAddress("GrandMasterFlush@domain.com", "Grandmaster Flush"); 

If the sender name provided does not exactly match that of the account the email will not get sent.



来源:https://stackoverflow.com/questions/23409202/email-not-working-not-able-to-receive-email-for-yahoo-email-id

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!