i working in php. have wriiten mail functionality using mailer extension of yii framework code as-
public function sendsecureemail($fromemail,$toemail,$subject,$message) { $settings=new settings(); $mailer = yii::createcomponent('application.extensions.mailer.emailer'); $mailer->issmtp(); $mailer->ishtml(true); $mailer->smtpauth = true; $mailer->smtpsecure = 'ssl'; $mailer->host =$settings->host; $mailer->port =$settings->port; $mailer->charset = 'utf-8'; $mailer->username =$fromemail; $mailer->password =$settings->password; $mailer->fromname = 'balaee.com'; // $mailer->addaddress($toemail); $mailer->subject = $subject; $mailer->ishtml(true); $mailer->body=$message; $mailer->addcc($toemail); // $mailer->addbcc=; if($mailer->send()) { echo "mail send successfully.please have check mail "; } else { echo "fail send message!"; } } where $setting->$host="mail.balaee.com",$setting->$port=25. in php.ini file settings as-
smtp = mail.balaee.com sendmail_from = noreply@balaee.com smtp_port = 25 when trying send mail giving me error as-smtp error: not connect smtp host. addtional settings needed do
i had similar error. turned out dns settings went blank in centos after server restarted. after setting them stared working again. hope helps.
Comments
Post a Comment