Welcome Guest, Not a member yet? Register   Sign In
sending email using Xampp
#1

can someone help me with this 

This is my code:

PHP Code:
public function send_get()
 
   {
 
     //configuracion para gmail

 
     $config = array(
 
     'protocol' => 'smtp',
 
     'smtp_host' => 'smtp.gmail.com',
 
     'smtp_port' => 465,
 
     'smtp_user' => '[email protected]',
 
     'smtp_pass' => 'correo',
 
   
     
);

 
     //Load email library
 
     $this->load->library('email',$config);


 
     $this->email->from('[email protected]''Foreigner');
 
     $this->email->to('[email protected]');
 
     $this->email->subject('Visitor');
 
     $this->email->message('Testing the email class.');

 
    if($this->email->send()){
 
      echo "your email was sent";
 
    }
 
    else {
 
      show_error($this->email->print_debugger());
 
    }
 
   }

This is the error i am recieving


[color=#4f5155][size=small]hello: F[/size][/color]

[color=#4f5155][size=small]The following SMTP error was encountered: F[/size][/color]

[color=#4f5155][size=small]Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.[/size][/color]
DateThu28 Dec 2017 22:03:38 +0100
From
"Foreigner" <************.com>
Return-
Path: <*****************.com>
To: ****************************
Subject: =?UTF-8?Q?Foreigner=20Visitor?=
Reply-To: <*******************.com>
User-AgentCodeIgniter
X
-Sender: *************************.com
X
-MailerCodeIgniter
X
-Priority(Normal)
Message-ID: <5a455c2a0e9c7@whitesharkmedia.com>
Mime-Version1.0 
Reply
#2

Use another SMTP

If you not using ssl in smtp host than you can use 567 smtp port

$config = array(
      'protocol' => 'smtp',
      'smtp_host' => 'smtp.gmail.com',
      'smtp_port' => 567,
      'smtp_user' => '[email protected]',
      'smtp_pass' => 'correo',
    
     );


If you are using ssl in smtp host than you can use 465 smtp port

$config = array(
      'protocol' => 'smtp',
      'smtp_host' => 'ssl://smtp.gmail.com',
      'smtp_port' => 465,
      'smtp_user' => '[email protected]',
      'smtp_pass' => 'correo',
    
     );
Reply
#3

(This post was last modified: 12-29-2017, 06:48 AM by jreklund. Edit Reason: Added syntax highlight )

@arugama: Gmail are picky on how you send your new lines and you may need to enable "Unsafe applications".
https://support.google.com/accounts/answ...0255?hl=en


PHP Code:
$config = [
 
'protocol' => 'smtp',
 
'smtp_host' => 'ssl://smtp.gmail.com',
 
'smtp_port' => 465,
 
'mailtype' => 'html',
 
'smtp_user' => '',
 
'smtp_pass' => '',
 
'newline' => "\r\n",
]; 


@XtreemDeveloper: Your first example are wrong. It's port 587 and you need to set smtp_crypto to tls.
Reply
#4

(This post was last modified: 12-29-2017, 07:22 AM by arugama.)

i made the change, and this happen

A PHP Error was encountered
Severity: Warning

Message: fsockopen(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routinesConfusedsl3_get_server_certificate:certificate verify failed

Filename: libraries/Email.php

Line Number: 2063

Backtrace:

File: C:\xampp\htdocs\rest\application\controllers\Email.php
Line: 69
Function: send

File: C:\xampp\htdocs\rest\application\libraries\REST_Controller.php
Line: 742
Function: call_user_func_array

File: C:\xampp\htdocs\rest\index.php
Line: 315
Function: require_once


the new configuration

 
PHP Code:
 public function send_get()
 
   {
 
     //configuracion para gmail

 
     $config = array(
 
     'protocol' => 'smtp',
 
     'smtp_host' => 'ssl://smtp.gmail.com',
 
     'smtp_port' => 465,
 
     'mailtype' => 'html',
 
     'smtp_user' => '',
 
     'smtp_pass' => '',
 
     'newline' => "\r\n",
 
    );

 
     //Load email library


 
     $this->load->library('email',$config);
 
     $this->email->set_newline("\r\n");

 
     $this->email->from('''');
 
     $this->email->to('');
 
     $this->email->subject(' Visitor');
 
     $this->email->message('Testing the email class.');

 
    if($this->email->send()){
 
      echo "your email was sent";
 
    }
 
    else {
 
      show_error($this->email->print_debugger());
 
    }
 
   
Reply
#5

https://curl.haxx.se/docs/caextract.html

Download cacert.pem and place it somewhere on your computer.
Open your php.ini file and add the following:
Code:
openssl.cafile = "C:\path\to\your\file\cacert.pem"
Reply
#6

awesome, work like a charm
Reply
#7

You can also use your own internet providers smtp server, I'm on Comcast and I use their's.

It's a good idea to setup your smtp in the php.ini file under the php directory.

If your on a Windows system you can use this Email Tool.

Test Mail Server Tool

On Ubuntu you can install and use this Tool.

swaks – SMTP test tool
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB