简体   繁体   English

无法使用 PHP SMTP 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件

[英]Unable to send email using PHP SMTP. Your server might not be configured to send mail using this methods

Hii guys i am trying to add contact Us form in my website but its shows嗨,伙计们,我正在尝试在我的网站中添加联系我们表格,但它显示

Failed to authenticate username.无法验证用户名。 Error: 535 Incorrect authentication data Unable to send email using PHP SMTP.错误:535 不正确的身份验证数据无法使用 PHP SMTP 发送电子邮件。 Your server might not be configured to send mail using this method.您的服务器可能未配置为使用此方法发送邮件。

$config = array(
'protocol' => 'smtp', // 'mail', 'sendmail', or 'smtp'
'smtp_host' => 'mail.31its.com', 
'smtp_port' => 2525,
'smtp_user' => 'dileep@xxx.com
',
'smtp_pass' => 'xxxx',
'smtp_crypto' => 'tls', //can be 'ssl' or 'tls' for example
'mailtype' => 'text', //plaintext 'text' mails or 'html'
'smtp_timeout' => '4', //in seconds
'charset' => 'iso-8859-1',
'wordwrap' => TRUE,

); );

Controller控制器

function send() {
    $this->load->config('email');
    $this->load->library('email');

    $from = $this->config->item('smtp_user');
    $to = $this->input->post('to');
    $name = $this->input->post('name');
    $subject = $this->input->post('subject');
    $message = $this->input->post('message');

    $this->email->set_newline("\r\n");
    $this->email->from($from);
    $this->email->to($to);

    $this->email->subject($subject);
    $this->email->message($message);

    if ($this->email->send()) {
        echo 'Your Email has successfully been sent.';
        $this->load->view('Index');
    } else {
        show_error($this->email->print_debugger());
    }
}

Views观看次数

<form method="post" action="<?=base_url('index.php/email')?>" enctype="multipart/form-data">
            <div class="form-group">
                <label for="exampleInputText">Name</label>
                <input type="text" id="name" class="form-control"  required="required">
            </div>
            <div class="form-group">
                <label for="exampleInputEmail1">Subject</label>
                <input type="text" id="subject" class="form-control"  required="required">
            </div>
            <div class="form-group">
                <label for="exampleInputEmail1">Email</label>
                <input type="email" id="to" class="form-control"  required="required">
            </div>

            <div class="form-group">
                <label for="exampleInputMessage">Message</label>
                <textarea class="form-control" id="message" rows="3"  required="required"></textarea>
            </div>
            <button type="submit" value="Send Email" href="#" class="submit-buttom"><i class="fa fa-2x fa-send" style="color:#eb2526"></i></button>
        </form>

Step 1 : Download PhpMailer for CodeIgniter from below link.第 1 步:从以下链接下载适用于 CodeIgniter 的 PhpMailer。 https://github.com/ivantcholakov/codeigniter-phpmailer https://github.com/ivantcholakov/codeigniter-phpmailer

Step 2 : Extract.第 2 步:提取。 Put third_party , libraries , helpers and config folder into your CI application folder.third_partylibrarieshelpersconfig文件夹放入您的 CI 应用程序文件夹中。

There will just index file(s) in each folder that will ask you to replace.每个文件夹中只会有索引文件会要求您替换。 Click replace and continue.单击替换并继续。

Step 3 :第 3 步:

Open application/config/email.php打开application/config/email.php

And do some updates according to your email account.并根据您的电子邮件帐户进行一些更新。 I am using gmail, so I am giving gmail settings as below.我正在使用 gmail,所以我提供了 gmail 设置,如下所示。

$config['protocol']         = 'smtp'; // 'mail', 'sendmail', or 'smtp'
$config['mailpath']         = '/usr/sbin/sendmail';
$config['smtp_host']        = 'smtp.gmail.com'; // if you are using gmail
$config['smtp_user']        = 'youremail@gmail.com';
$config['smtp_pass']        = 'sdkfjsk089sdfskKJ'; // App specific password
$config['smtp_port']        = 465; // for gmail
$config['smtp_timeout']     = 5;  

Step 4 : Now, in your controller where you want to send email.第 4 步:现在,在您要发送电子邮件的控制器中。 Use below code and its all done.使用下面的代码并完成所有操作。

$this->load->library('email');
$this->email->from('youremail@gmail.com')
     ->reply_to('youremail@gmail.com')
     ->to('someone@somedomain.com')
     ->subject("Subject")
     ->message("Your Message")
     ->set_mailtype('html')
     ->send();

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Codeigniter 3 无法使用 PHP ZC2239A92BDE29F0A00F9173193CC2FE 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - Codeigniter 3 Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method 无法使用 PHP SMTP 发送 email。您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method CodeIgniter中的AWS SMTP邮件错误(无法使用PHP SMTP发送电子邮件。您的服务器可能未配置为使用此方法发送邮件。) - AWS SMTP mail error in CodeIgniter (Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.) 无法发送AUTH LOGIN命令。 错误:无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Failed to send AUTH LOGIN command. Error: Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method SMTP错误:220 smtpauth.net4india.com准备就绪无法使用PHP SMTP发送电子邮件。 您的服务器可能未配置 - SMTP error: 220 smtpauth.net4india.com ready Unable to send email using PHP SMTP. Your server might not be configured Codeigniter:您的服务器可能未配置为使用此方法发送邮件。 无法使用 PHP SMTP 发送电子邮件 - Codeigniter: Your server might not be configured to send mail using this method. Unable to send email using PHP SMTP 无法使用 PHP mail() 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP mail(). Your server might not be configured to send mail using this method 遇到错误无法使用 PHP mail() 发送 email。 您的服务器可能未配置为使用此方法发送邮件 - An Error Was Encountered Unable to send email using PHP mail(). Your server might not be configured to send mail using this method 无法使用 PHP Sendmail 发送电子邮件。 您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using PHP Sendmail. Your server might not be configured to send mail using this method 无法使用codeigniter发送电子邮件-错误:您的服务器可能未配置为使用此方法发送邮件 - Unable to send email using codeigniter-Error:Your server might not be configured to send mail using this method
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM