Call 1300 467 843

Sending email via your website
Minimize

OZ-KBA-3017: Sending Email via your Website

This KB will explain:

•    What Email Modules are Available
•    Code Examples
•    Possible Error

Article


What Email Modules are included with OzHosting.com?

OzHosting.com does not include any Email Generation Code. If you wish to send email from your website you will need to develop the code to do so in your selected language.

Code Examples

ASP1

Within ASP you can use the “CDO.Message” command to send email.
<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.TextBody="This is a message."
myMail.Send
set myMail=nothing
%>

PHP2

Within PHP you can use the “mail()” function to send email.
<?php
$to      = 'nobody@example.com';
$subject = 'the subject';
$message = 'hello';
$headers = 'From: webmaster@example.com' . "\r\n" .
    'Reply-To: webmaster@example.com' . "\r\n" .
    'X-Mailer: PHP/' . phpversion();

mail($to, $subject, $message, $headers);
?>

Note: The code here is provided as an example and is not designed to be used in a Live Site.

Possible Error

When sending email via the code in your website you will need to specify an address to send from. This address will need to be a real email address or the generated emails may not be delivered correctly. This is because all OzHosting.com Mail hosting uses SPF Records and if the mailbox does not exist on the OzHosting.com server the email may not be delivered.

Example Code Sources

1 – http://www.w3schools.com/asp/asp_send_email.asp
2 – http://au.php.net/mail