Infinite Menus, Copyright 2006, OpenCube Inc. All Rights Reserved.  
 
 
Support Scripting


- Perl Script error
- Redirect traffic to a permanent URL
- Send emails from Web Application
 
Perl Script error


We make a standard install of ActiveState Perl on all our servers to enable customers to run Perl scripts. One of the frequent questions we get asked is why when the Perl script is accessed it gives this error:
"The specified CGI application misbehaved by not returning a complete set of HTTP headers"

This is a generic error that means running the Perl script has been unsuccessful. We cannot provide support for third party Perl scripts, so if this error comes up:
1) Make sure the script is named *.pl or *.cgi
2) Check the script is compatible with Windows and IIS
3) Make sure you have filled in all appropriate variable correctly
4) Contact the author for assistance.

If you do not believe the script is at error, you can try the following simple test script:

#!/usr/local/bin/perl
print "Content-type: text/html\n\n";
print "<H1>Hello World</H1>n";

If this executes and displays "Hello World" in your browser then Perl is functioning correctly on that server.

 
Redirect traffic to a permanent URL


Scenario:
When someone type www.tj-hosting.net or tj-hosting.net we want to keep the url as www.tj-hosting.com.

<%
DIM domain
domain = Lcase(REQUEST.SERVERVARIABLES("SERVER_NAME"))

SELECT CASE domain

CASE "tj-hosting.net"
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.tj-hosting.com"

CASE "www.tj-hosting.net"
Response.Status = "301 Moved Permanently"
Response.AddHeader "Location", "http://www.tj-hosting.com"
END SELECT
%>

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.

 
Send emails from Web Application


- Introduction.
At TJ-Hosting it is required that all email messaging have to be authenticated, any attempt to send anonymous email will fail. To send email from your website you will need to configure your scripts to authenticate against your designated SMTP server (usually smtp.yourdomain.com or smtp.websoon.com) with one of your existant email accounts at TJ-Hosting mail servers.
- Sending emails in ASP.NET 2.0
// using System.Net.Mail;
// using System.Net;

SmtpClient smtpClient = new SmtpClient("smtp.domainHosted.com");

smtpClient.Credentials = new NetworkCredential("user1@domainHosted.com", "passwordHere");

MailMessage message = new MailMessage();

message.From = new MailAddress(user1@domainHosted.com);
message.To.Add(new MailAddress(nick@example.com));
message.To.Add(new MailAddress(ben@example.com));

message.Subject = "This is my subject";
message.Body = "This is the content";

smtpClient.Send(message);

- Sending mail from ASP via CDO object. (What happened to CDONTS?)
With the introduction of Windows Server 2003, Microsoft dropped support for CDONTS. Therefore, applications that use CDONTS do not function on Windows Server 2003, furthermore CDONTS does not provide the means to send email via authenticated SMTP.
<%
Set myMail=Server.CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="me@example.com"
myMail.To="you@example.com"
myMail.TextBody="This is a message."
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.YourDomain.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25
'Authentication
myMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Account@YourDomain.com"
myMail.Configuration.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Password"
myMail.Configuration.Fields.Update
myMail.Send
%>

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.

References:
Microsoft Windows Server 2003 does not install CDONTS:
http://support.microsoft.com/default.aspx?scid=kb;en-us;315197

- Sending mail from ASP with Persits ASPEmail object.
Consult the excelent documentation that Persits have put together at:
http://www.aspemail.com/manual.html
Here is a short example:
<%
Set objMail = Server.CreateObject("Persits.MailSender")
objMail.Host = "smtp.DomainHosted.com"
objMail.Username = "account@DomainHosted.com"
objMail.Password = "Password"

objMail.From = "me@example.com" 'from me
objMail.AddAddress ("you@example.com") 'to you
objMail.Subject = "Hello you."
objMail.body = "This is a test message."
On Error Resume Next
objMail.Send
If Err <> 0 Then
Response.Write "An error occurred: " & Err.Description
End If
objMail = Nothing
%>

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.

- Sending mail from ASP.NET.

Here is a C# version.
// using System.Web.Mail;
MailMessage eMail = new MailMessage();
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"] = 1;
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendusername"] = "account@domainHosted.com";
eMail.Fields["http://schemas.microsoft.com/cdo/configuration/sendpassword"] = "password";
eMail.To = "someone@yahoo.com"; // Recipients
eMail.From = "somebody@yahoo.com";
eMail.Subject = "This is the subject line";
eMail.Body = "Test Message";
SmtpMail.SmtpServer = "smtp.domainHosted.com";
SmtpMail.Send(eMail);

And a VisualBasic version
Dim eMail = new MailMessage()
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "account@domainHosted.com"
eMail.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"

eMail.To = "someone@yahoo.com"
eMail.From = "somebody@yahoo.com"
eMail.Subject = "This is the subject line"
eMail.Body = "Test Message"
SmtpMail.SmtpServer = "smtp.domainHosted.com"
SmtpMail.Send(eMail)

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.
- Sending mail from PHP.

This sample uses the Pear Mail package. The package is already in the INCLUDE path.

http://pear.php.net/package/Mail
<?
include_once("Mail.php");
$recipients = 'mail_to@domain.mail';
$headers["From"] = 'mail_from@domain.mail';
$headers["To"] = 'mail_to@domain.mail';
$headers["Subject"] = "Test message";
$body = "TEST MESSAGE!!!";
$params["host"] = 'smtp.domainHosted.com';
$params["port"] = "25";
$params["auth"] = true;
$params["username"] = 'account@domainHosted.com';
$params["password"] = "password";
// Create the mail object using the Mail::factory method
$mail_object =& Mail::factory("smtp", $params);
$mail_object->send($recipients, $headers, $body);
echo "Email sent."
?>

These examples may not work for you without certain modifications.
The purpose of the examples is to give you a general idea on the topic.

- Setting up a Form to Mail script.
To set-up a very easy form to mail script you may download the following script. To configure it follow the instructions inside the formmail.asp file.

http://TJ-Hosting.com/support/downloads/formmail.zip
 
 
  Support Centre - FAQ
ASP.net
Databases
Coding Components
Scripting Support
Downloads

Demo LiveStats
Demo WebMail
Demo Hosting Manager
 
Disclaimer Privacy Policy Service Guarantee Terms & Conditions

807-966 Inverhouse Dr., Mississauga-ON, L5J4B6 - contact@tj-hosting.com
Phone: 905-919-9949 - Fax: 905-823-5895 - Toll-Free: 1-866-818-3162
© 2004-2014 TJ-Hosting - All Rights Reserved.