I wonder if someone can help me. I'm not a coder by profession and i am learning PHP as i go along really as i've inherited a website since our developer left. One of the functions on our site is not working which is based on email notifications. I wonder if someone can help me diagnose where the problem is. I've tested that the SMTP and account details are fine by using Outlook to send a message using the same account details as well as using Telnet.
So a function has been created in the commonfunction.php file
Code: Select all
function site_mail1($from,$to,$subject,$body){
set_include_path('c:\php\pear');
require_once "Mail.php";
$host = "xx.xxx.xxx.xxx";
$port = "25";
$username = "xxx@xxxxxxxx.org.uk";
$password = "xxxxxxxxx";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject,
'Content-Type' => 'text/html');
$smtp = Mail::factory('smtp',
array ('host' => $host,
'port' => $port,
'auth' => true,
'username' => $username,
'password' => $password));
//echo $to."--<br>".$headers."--<br>".$body;
$mail = $smtp->send($to, $headers, $body);
if (PEAR::isError($mail)) {
//echo PEAR_Error::getMessage ($mail );
return TRUE;
} else {
return FALSE;
}
}
Code: Select all
<?php
$docRoot = substr($_SERVER["SCRIPT_FILENAME"], 0, strlen($_SERVER["SCRIPT_FILENAME"]) - strlen($_SERVER["SCRIPT_NAME"]));
include ($docRoot ."/includes/config.inc.php");
$Name="Site Mail";
$from= "xxx@xxxxx.co.uk";
$to="xxxx@xxxx.com";
$bc="xxxx@xxxx.com";
$subject= "[ ]"."A new message arrived in your message centre";
$body = '
<table width="500" border="1" cellpadding="0" cellspacing="0" bordercolor="#7A7A7A" align="center">
<tr>
<td height="20" align="center" class="panel_head"><strong><font color="#000">Message Centre</font></strong></td>
</tr>
<tr>
<td height="20" align="center" bordercolor="E7E7E7">A new message has arrived for you</td>
</tr>
</table>';
if(site_mail1($from,$to,$subject,$body)){
echo "SUCCESS";
}else{
echo "FAILURE";
}
?>
If anyone can point me in the right direction that would be most helpful.
Thanks