Our SMTP servers require that you pass SMTP authentication before relaying email from a php application. You can use the code below to define SMTP authentication.
<html>
<head><title>Test email via php</title></head>
<body>
<?php
require_once "Mail.php";
$from = "Sender <postmaster@YourHostedDomainName.com>";
$to = "Recipient <user@YourHostedDomainName.com>";
$subject = "This is a test email sent via php";
$body = "This is a test email";
$host = "[Mail Server Name]";
$username = "postmaster@YourHostedDomainName.com";
$password = "email_password";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($to, $headers, $body);echo "mail sent";
?>
</body>
</html>
If you run into problems when using this code, please post in the DiscountASP.NET or Everleap community forum. Technical support is unable to assist with specific coding issues.
Article ID: 1058, Created: July 2, 2012 at 7:41 AM, Modified: September 10, 2015 at 2:01 PM