Problem with using PHPMailer for SMTP

前端 未结 3 979
陌清茗
陌清茗 2021-01-26 16:30

I have used PHPMailer for SMTP and there is problem in sending mail with error \"Mailer Error: The following From address failed: no-reply@mydomain.org.uk\"

My code is a

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-26 16:41

    I am using YII's Mailer with PHPMailer, and this works for me:

    $mail = Yii::createComponent('application.extensions.mailer.EMailer');
    $mail->Username           = $this->SMTP_USERNAME;  // SMTP username
    $mail->Password           = $this->SMTP_PASSWORD; // SMTP password
    $mail->SMTPAuth           = true;
    $mail->From               = $this->fromAddress;
    $mail->Host               = $this->SMTP_SERVER_ADDRESS;
    $mail->FromName           = $this->fromName;
    $mail->CharSet            = 'UTF-8';
    $mail->Subject            = Yii::t('mailer', $this->subject);
    $mail->Body               = $this->message;
    $mail->AddReplyTo($this->toAddress);
    $mail->AddAddress($this->toAddress);
    $mail->IsSMTP(true);
    $mail->IsHTML(true);
    $mail->Send();
    

    Hope that helps?

提交回复
热议问题