Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 ASP.NET
 MailMessage fails to yahoo and hotmail ( using Sys

Author  Topic 

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-01-21 : 11:45:16
Hello,

I have the following web mail code, which works fine and delivers to my personal email and office mail, however it fails to deliver to yahoo and hotmail and doesnt even show up in the junk mail folders.

What could be wrong here. The smtp details are correct and its hosted on a remote server.

What is wrong here ?

thanks



Here is my code.

1st I have a class file, below which has the new_signup_sendmail





using System.Net.Mail;


/// <summary>
/// Summary description for new_signup_sendmail
/// </summary>
public class new_signup_sendmail
{

public new_signup_sendmail(string from1, string to1, string bcc1, string cc1, string subject1, string body1)
//( from , to, bcc, cc, subject, body)
{
try
{
MailMessage NewEmail = new MailMessage();
NewEmail.From = new MailAddress(from1);
NewEmail.To.Add(new MailAddress(to1));
{
NewEmail.Bcc.Add(new MailAddress(bcc1));
}
if ((cc1 != null) && (cc1 != string.Empty))
{
NewEmail.CC.Add(new MailAddress(cc1));
}
NewEmail.Subject = subject1;
NewEmail.Body = body1;
NewEmail.IsBodyHtml = true;
SmtpClient mSmtpClient = new SmtpClient();
// Send the mail message
mSmtpClient.Send(NewEmail);
//this.Label1.Text = "Email sent successful.";
}
catch
{
// this.Label1.Text = "Email sent failed";
}

}
}





Then I have the button1_click event here



protected void Button1_Click(object sender, EventArgs e)
{
string from1 = "info@something.com";// like username@server.com
string to1 = To.Text; //your To Mail
string bcc1 = "";
string cc1 = "";
string subject1 = Subject.Text;
string body1 = Body.Text;
new_signup_sendmail send_mail = new new_signup_sendmail(from1, to1, bcc1, cc1, subject1, body1);

}




and i have the code in my web.config file. email is Edited



    <system.net>
<mailSettings>
<smtp>
<network host="mail.something.com" port="25" userName="info@something.com" password="123456"/>
</smtp>
</mailSettings>
</system.net>



rudesyle
Posting Yak Master

110 Posts

Posted - 2008-01-28 : 11:59:43
Try escaping userName="info@something.com" in the web.config file. It's an XML file, so the asterisk is probably the problem.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-01-28 : 13:57:55
throws an exception

"NO SUCH USER"
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2008-01-28 : 14:12:57
the smtp server doesn't allow sending to yahoo and hotmail

_______________________________________________
Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
SSMS Add-in that does a few things: www.ssmstoolspack.com <- new version out
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-01-28 : 14:34:05
:(
Go to Top of Page

rgombina
Constraint Violating Yak Guru

319 Posts

Posted - 2008-02-01 : 07:59:16
Go to your webmail setting and forward to yahoo from there. So, to1 = "me@mydomain.com" and set Forward to (webmail) = me@yahoo.com.

Most hosting company does not allow external destination email.
Go to Top of Page
   

- Advertisement -