簡體   English   中英

codeignater 郵件 function 在共享托管服務器上不起作用

[英]codeignater mail function not working on shared hosting server

$this->load->library('email');
//Email content
$htmlContent = '<h1>Don`t worry, we all forget sometimes </h1>';
$htmlContent .= '<p>Hi,</p>';
$htmlContent .= '<p>You`ve recently asked to reset the password for this account</p>';
$htmlContent .= '<span>Your Forgot Otp Is :</span>';
$this->email->to($email);
$this->email->from('abc@gmail.com','abc');
$this->email->subject('Forget Password');
$this->email->message("$htmlContent"." "."<p><h2>$forgotOtp</h2></p>"."<p>Thanks,</p>"."<p>Team</p>"." "." <p> abc<p>");
          //Send email
$this->email->send();

$this->ApiModel->UpdateForgotOtp($email,$forgotOtp);
print_r(json_encode([
        'message'=>'success',
       'status'=>200
]));

此代碼不適用於共享主機服務器。不會顯示錯誤消息

首先,您需要像這樣設置發送 email 的配置,

$config = array(
    'mailtype' => 'html',
    'protocol' => 'smtp',
    'smtp_host' => 'YOUR_HOST',
    'smtp_port' => 2525,
    'smtp_user' => 'USERNAME',
    'smtp_pass' => 'PASSWORD',
    'crlf' => "\r\n",
    'newline' => "\r\n"
);
$this->load->library('email');

// Initialize the library
$this->email->initialize($config );

//Email content
$htmlContent = '<h1>Don`t worry, we all forget sometimes </h1>';
$htmlContent .= '<p>Hi,</p>';
$htmlContent .= '<p>You`ve recently asked to reset the password for this account</p>';
$htmlContent .= '<span>Your Forgot Otp Is :</span>';
$this->email->to($email);
$this->email->from('abc@gmail.com','abc');
$this->email->subject('Forget Password');
$this->email->message("$htmlContent"." "."<p><h2>$forgotOtp</h2></p>"."<p>Thanks,</p>"."<p>Team</p>"." "." <p> abc<p>");
          //Send email
$this->email->send();

$this->ApiModel->UpdateForgotOtp($email,$forgotOtp);
print_r(json_encode([
        'message'=>'success',
       'status'=>200
]));

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM