An Error Was Encountered
<p>I am studying a old tutorial and facing problems that are given below, please help me.
I think this is easy but there is some problemwhich i don't able to understand.</p>

<p>Facing an error while sending mail using codeigniter, error is given below:</p>

<pre><code>    220 mx.google.com ESMTP f4sm2807502pbg.56 
    hello: 250-mx.google.com at your service, [119.30.39.69]
    250-SIZE 35882577
    250-8BITMIME
    250-AUTH LOGIN PLAIN XOAUTH
    250-ENHANCEDSTATUSCODES
    250 PIPELINING

    from: 250 2.1.0 OK f4sm2807502pbg.56

    to: 553-5.1.2 We weren't able to find the recipient domain. Please check for any
    553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods,
    553 5.1.2 or other punctuation after the recipient's email address. f4sm2807502pbg.56

    The following SMTP error was encountered: 553-5.1.2 We weren't able to find the recipient domain. Please check for any 553-5.1.2 spelling errors, and make sure you didn't enter any spaces, periods, 553 5.1.2 or other punctuation after the recipient's email address. f4sm2807502pbg.56

    data: 503 5.5.1 RCPT first. f4sm2807502pbg.56

    The following SMTP error was encountered: 503 5.5.1 RCPT first. f4sm2807502pbg.56
    502 5.5.1 Unrecognized command. f4sm2807502pbg.56
    The following SMTP error was encountered: 502 5.5.1 Unrecognized command. f4sm2807502pbg.56
    Unable to send email using PHP SMTP. Your server might not be configured to send mail using this method.

    User-Agent: CodeIgniter
    Date: Wed, 11 Apr 2012 12:46:40 +0000
    From: "myname" 
    Return-Path: 
    To: $email
    Subject: =?utf-8?Q?This_is_an_email_test?=
    Reply-To: "m.methun@gmail.com" 
    X-Sender: m.methun@gmail.com
    X-Mailer: CodeIgniter
    X-Priority: 3 (Normal)
    Message-ID: &lt;4f857d304b4f7@gmail.com&gt;
    Mime-Version: 1.0


    Content-Type: multipart/mixed; boundary="B_ATC_4f857d304b520"

    This is a multi-part message in MIME format.
    Your email application may not support this format.

    --B_ATC_4f857d304b520
    Content-Type: text/plain; charset=utf-8
    Content-Transfer-Encoding: 8bit

    Its working. Great!


    --B_ATC_4f857d304b520
    Content-type: text/plain; name="yourinfo.txt"
    Content-Disposition: attachment;
    Content-Transfer-Encoding: base64

    ZmZmZmZmZmY=

    --B_ATC_4f857d304b520--
</code></pre>

<p>My program is given below:</p>

<p><strong>email.php</strong></p>

<pre><code>&lt;?php
class Email extends CI_Controller
{
    function __construct()
    {
        parent::__construct();
    }


    function index(){

   $this-&gt;load-&gt;view('newsletter');

}


function send()
{

    $this-&gt;load-&gt;library('form_validation');

    //field name, error message, validation rules
    $this-&gt;form_validation-&gt;set_rules('name', 'Name', 'trim|required');
    $this-&gt;form_validation-&gt;set_rules('email', 'Email Address', 'trim|required|valid_email');

    if($this-&gt;form_validation-&gt;run() == FALSE)
    {                                            // this is from validation..that works
      $this-&gt;load-&gt;view('newsletter');
    }  
   else
   {
   // validation has passed. now send email

   $name = $this-&gt;input-&gt;post('name');
   $email = $this-&gt;input-&gt;post('email');


    $this-&gt;load-&gt;library('email');
    $this-&gt;email-&gt;set_newline("\r\n");

    $this-&gt;email-&gt;from('m.methun@gmail.com', 'myname');
    $this-&gt;email-&gt;to('$email');
    $this-&gt;email-&gt;subject('This is an email test');
    $this-&gt;email-&gt;message('Its working. Great!');

   // attachment of file...in sending mail
    $path = $this-&gt;config-&gt;item('server_root');
   $file = $path . '/ci/attachments/yourinfo.txt';
    $this-&gt;email-&gt;attach($file);
   //end


   if($this-&gt;email-&gt;send())
   {
     echo ' mail send ';
   }
   else
    {
     show_error($this-&gt;email-&gt;print_debugger());
     }
   }

  }
 }
 ?&gt;      
</code></pre>

<p><strong>newsletter.php</strong>   </p>

<pre><code> &lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;style type = "text/css"&gt;
  label{ display: block; };
 &lt;/style&gt;

&lt;/head&gt;

&lt;body&gt;
    &lt;div id ="newsletter_form"&gt;

        &lt;?php echo form_open('email/send'); ?&gt;

        &lt;?php 

        $name_data = array(
        'name'=&gt;'name',
        'id' =&gt; 'name',
        'value' =&gt; set_value('name')
         );

        ?&gt;

        &lt;?php 
         //three ways of taking input..from form 
         ?&gt;
        &lt;p&gt;&lt;label for = "name" &gt; Name:&lt;/label&gt;
                  &lt;?php echo form_input($name_data); ?&gt; &lt;/p&gt;

        &lt;p&gt;&lt;label for = "name" &gt;Email Address:&lt;/label&gt;
            &lt;input type ="text" name="email" id="email"          
            value = "&lt;?php echo set_value('email'); ?&gt;"&gt;
        &lt;/p&gt;                  


       &lt;p&gt; &lt;?php echo form_submit('submit','Submit'); ?&gt; &lt;/p&gt;       

       &lt;?php 
       // end of taking inputs...
        ?&gt;  


        &lt;?php echo form_close(); ?&gt;
        &lt;?php echo validation_errors('&lt;p class ="error" &gt;'); ?&gt;
    &lt;/div&gt;



&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><strong>config/email.php</strong></p>

<pre><code>&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');



$config['protocol'] = 'smtp';
$config['smtp_host']='ssl://smtp.googlemail.com';
$config['smtp_port']=465;

$config['smtp_user']='m.methun@gmail.com';
$config['smtp_pass']='methun123';

?&gt;
</code></pre>

<p>I think the problem is simple but i am unable to fixed it.</p>
