Welcome Guest, Not a member yet? Register   Sign In
sending email via gmail
#1

I'm trying to send emails with gmail attachment but codeigniter always gives me the error:
to: 555 5.5.2 Syntax error. n2sm18426280wra.89 - gsmtp
The following SMTP error was encountered: 555 5.5.2 Syntax error. n2sm18426280wra.89 - gsmtp
in any case, however, the email arrives correctly at its destination!
below is the code I use to send

PHP Code:
function sendEmail($to ''$subject  ''$body ''$attachment '') {
 
       
    $controller 
=& get_instance();
 
       
    $controller
->load->helper('path'); 

 
   // Configure email library

 
   $config = array();
 
   $config['useragent'           "CodeIgniter";
 
   $config['mailpath'            "/usr/bin/sendmail"// or "/usr/sbin/sendmail"
 
   $config['protocol'            "smtp";
 
   $config['smtp_host'           "ssl://smtp.gmail.com";
 
   $config['smtp_port'           "465";
 
   $config['smtp_timeout'        '30';
 
   $config['smtp_user'           "[email protected]";
 
   $config['smtp_pass'           "password";
 
   $config['mailtype'            'html';
 
   $config['charset'             'utf-8';
 
   $config['newline'             "\r\n";
 
   $config['crlf'                "\n";
 
   $config['wordwrap'            TRUE;
 
   $config['allowed_types'       'pdf';
 
   $config['max_size'            '100000';

 
   $controller->load->library('email');

 
   $controller->email->initialize($config);   
    $controller
->email->set_newline("\r\n");
 
   $controller->email->set_crlf("\r\n");
 
   if($attachment != '')
 
   {
 
       $controller->email->attach(base_url()."uploads/interventi/" .$attachment);
 
   }

 
   $controller->email->from('[email protected]','Test Test');
 
   
    $controller
->email->to($to,$to);
 
   
    $controller
->email->subject('Test message');

 
   $controller->email->message($body);    


 
   if($controller->email->send()){
 
       $this->session->set_flashdata('msg''Email sent correctly');
 
   }
 
   
    else
    
{
 
       show_error($controller->email->print_debugger());
 
       
    
}

Reply
#2

@emanuele.zamengo

Try this link: https://stackoverflow.com/questions/4421...ntax-error
Reply
#3

PHP Code:
$config = array();

$config['protocol'    'smtp'  // 'mail', 'sendmail', or 'smtp'
$config['smtp_host'   'smtp.gmail.com'
$config['smtp_port'   465,
$config['smtp_user'   '[email protected]',
$config['smtp_pass'   'password',
$config['smtp_crypto' 'ssl'  //can be 'ssl' or 'tls' for example
$config['smtp_timeout'] = '30'   //in seconds 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(05-02-2019, 06:46 AM)php_rocs Wrote: @emanuele.zamengo

Try this link: https://stackoverflow.com/questions/4421...ntax-error

thanks in this way it works !!
Reply
#5

@emanuele.zamengo

Awesome, glad I could assist.
Reply
#6

(05-02-2019, 10:28 AM)php_rocs Wrote: @emanuele.zamengo

Awesome, glad I could assist.

I ask one last thing:
if I manually set the recipient address in this way
PHP Code:
Controller-> Email-> to ('<[[email protected]>']test.test@gmail.com>'[/email]); 

everything works correctly
if instead I compose it like this:
PHP Code:
Controller-> Email-> to ('<'. $ To'>'); 

from error anyway!
where's the problem?
Reply
#7

@emanuele.zamengo,

Then this tells me that only the first solution works and maybe there was a change to what is acceptable by Google.
Reply
#8

(05-03-2019, 05:15 PM)php_rocs Wrote: @emanuele.zamengo,

Then this tells me that only the first solution works and maybe there was a change to what is acceptable by Google.

yes!
Reply




Theme © iAndrew 2016 - Forum software by © MyBB