Using AfterLogic WebMail (PHP) without SMTP

WebMail Pro WebMail Pro WebMail Pro PHP PHP PHP SMTP SMTP SMTP Apache Apache Apache shared hosting shared hosting shared hosting connection connection connection problem problem problem send mail send mail send mail customization customization customization
By default, both Lite and Pro versions of AfterLogic WebMail (PHP) require SMTP access for sending mails. Unfortunately, some hosting providers disallow using SMTP from PHP scripts and thus make it impossible to run WebMail.

If you still like to use WebMail Lite on your hosting account, it is possible to modify the source code so that standard mail() function of PHP is used instead of SMTP. This would require changing SendMail function under CSmtp class (common/class_smtp.php script). We recommend adding the following at the beginning of the function code rather than replacing it:

$msg = $message->TryToGetOriginalMailMessage();
$arr = explode("\r\n\r\n", $msg, 2);
$body = $arr[1];
$head = explode("\r\n",$arr[0]);
$hdrs=''; $hdr_to=''; $hdr_subj=''; $head_key='';
foreach($head as $key => $value)
{
   $head_val=$value;
   if (($epos=strpos($value,':'))!==false)
   {
       $head_key = substr($value,0,$epos); $head_val=substr($value,2+$epos);
   }
   if (($head_key)=='To') $hdr_to.=$head_val."\r\n";
   elseif (($head_key)=='Subject') $hdr_subj.=$head_val."\r\n";
   else $hdrs.=$value."\r\n";
}
if (($hdr_bcc=($message->Headers->GetHeaderValueByName("BCC")))!="") $hdrs.="Bcc: $hdr_bcc\r\n";
return (mail($hdr_to, $hdr_subj, $body, $hdrs));


Certainly, it doesn't make sense specifying SMTP server address and port, those will be ignored. If you use this approach, it might be worth notifying your users of this.

This modification is based on the solution offered by forum community and thus is available on AS IS basis. Modification was offered for WebMail Lite but should work with Pro version as well.
Back to articles list