can not send email by php on my server

blog

Verified User
Joined
Jan 28, 2011
Messages
131
Hi

I can get/send email by Squirrelmail

But when use phpmailer to send email from my website email is not sent

this is function:

function send()
{
$mail = new PHPMailer();
$mail->CharSet = 'UTF-8';
$mail->IsSMTP();
$mail->SMTPAuth = true;
$mail->Host = 'mail.mydomain.com';
$mail->Port = 465;
$mail->Username = 'info@mydomain.com';
$mail->Password = 'password';
$mail->From = 'noreply@mydomain.com';
$mail->FromName = 'myname';
$mail->AddAddress($this->_tpl_vars['TO']);
if (isset($this->_tpl_vars['CC']))
{
$cc = explode(';', $this->_tpl_vars['CC']);
foreach ($cc as $c)
if (!empty($c))
$mail->AddCC($c);
}
$mail->AddReplyTo('noreply@mydomain.com');
$i = array();
$i = 3;
$mail->IsHTML(true);
$mail->Subject = $this->_tpl_vars['SUBJECT'];
$mail->Body = $this->_tpl;
@$mail->Send();
}
 

zEitEr

Super Moderator
Joined
Apr 11, 2005
Messages
13,927
Location
GMT +7.00
Hello,

Try and change:

PHP:
@$mail->Send();
to

PHP:
if(!$mail->Send())  {
   echo "Message could not be sent. <p>";
   echo "Mailer Error: " . $mail->ErrorInfo;
   exit;
} 
echo "Message has been sent";
and post here what error you've got there.
 

SeLLeRoNe

Super Moderator
Joined
Oct 9, 2004
Messages
6,790
Location
A Coruña, Spain
Does you have a valid SSL cert?

I'm not a programmer, but as far i can see you are connecting to an SSL port without specify anywhere the smtps protocol (maybe in front of the mail.domain.com you should put smtps:// )

For be sure, i would suggest for now to DONT use SSL, so keep everything like that but change port from 465 to 587.

Regards
 
Top