Saturday, November 12, 2011

Javascript Popup Window

There are some cases we need to launch new popup window when user click a link or button. For example, when we want to show some privacy detail information when user clicks Privacy link. Typically this is done by Javascript and normally the popup window does not have toolbar, menu, scollbar and status bar.

So here is popup window inline javascript. It pops up a new window whose size is 470 x 150. return false statement is added at the end so that it keeps current window as well.

<a href="/Privacy.htm"
    onclick="javascript: window.open('/Privacy.htm','_blank',
          'resizable=no,toolbar=no,scrollbars=no,menubar=no,status=no,directories=no,
           width=470,height=150', false); return false;">Privacy</a>

Of course, the Javascript can be placed to <Script> section in HEAD and simply calls the Javascript function in OnClick event.

Wednesday, November 9, 2011

GoDaddy email error : 553 sorry, your mail was administratively denied

In the previous post I explained about sending SMTP mail from ASP.NET. When I use it in Arvixe web hosting, it went well. But, I happened to try GoDaddy web hosting with the same source code. Then now I got the the following exception : 553 sorry, your mail was administratively denied. There have been some complaint about this problem. With some struggle, I ended up with the following workaround.

(1) GoDaddy SMTP server settings in web.config are as follows. Please note that you do not need username and password information here.

<system.net>
   <mailSettings>
     <smtp>
       <network host="relay-hosting.secureserver.net" port="25" />
      </smtp>
</mailSettings>
</system.net>
(2) I used Contact Form in ASP.NET and took FROM email address from textbox, which most people do. The thing is GoDaddy mail system denied this kind of email address.

string from = txtEmail.Text.Trim();               
string subject = txtSubject.Text.Trim();               
string body = txtMsg.Text;
string to = WebConfigurationManager.AppSettings["MailAccount"];
body = string.Format("From: {0}{1}{2}", from, Environment.NewLine, body);               
from = to;  // Do not use user's email address
MailMessage message = new MailMessage(from, to, subject, body);
SmtpClient smtp = new SmtpClient();
smtp.Send(message);

So the workaround is to use my domain email account in FROM part and put the customer's email to subject or body part. I don't like it but it worked anyway...