从cpanel发送SMTP电子邮件

时间:2016-09-29 12:09:37

标签: php codeigniter email

我正在使用godaddy共享主机是在那里我读到它不可能从共享主机使用SMTP发送电子邮件有任何替代方式..我试图使用codeigniter发送电子邮件,但它& #39;根本不工作

$this->email->clear();
                $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
                $this->email->to($user->email);
                $this->email->subject($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject'));
                $this->email->message($message);

                if ($this->email->send())
                {
                    $this->set_message('forgot_password_successful');
                    return TRUE;
                }
                else
                {
                    $this->set_error('forgot_password_unsuccessful');
                    return FALSE;
                }

1 个答案:

答案 0 :(得分:1)

检查:GoDaddy POP and SMTP Server Settings

检查库配置电子邮件,并查看托管服务提供商查找的电子邮件帐户,选择并查看手动配置。

Documentation Codeigniter Email

<?php 
public function sendEmailSMTP(){
  $this->load->library("email");
  $configEmail = array(
    'useragent' => "CodeIgniter",
    'mailpath'  => "/usr/bin/sendmail", // or "/usr/sbin/sendmail"
    'protocol'  => 'smtp',
    'smtp_host' => 'URL',// URL check: http://www.yetesoft.com/free-email-marketing-resources/godaddy-pop-smtp-server-settings/,
    'smtp_port' => 465, // Usually 465
    'smtp_crypto' => 'ssl', // or tls
    'smtp_user' => 'youremail@yourdomain.com',
    'smtp_pass' => 'AccountPasswordEmail',
    'mailtype'  => 'html',
    'charset'   => 'utf-8',
    'newline'   => "\r\n"
   );    

  //Load config
  $this->email->initialize($configEmail);
  $this->email->from($this->config->item('admin_email', 'ion_auth'), $this->config->item('site_title', 'ion_auth'));
  $this->email->to($user->email);
  $this->email->subject(($this->config->item('site_title', 'ion_auth') . ' - ' . $this->lang->line('email_forgotten_password_subject'));
  $this->email->message($message);
  $this->email->send();

  // See result
  echo $this->email->print_debugger();

} // End sendEmailSMTP()