CodeIgniter Forums
How can i send email via form in CI ? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forum-21.html)
+--- Thread: How can i send email via form in CI ? (/thread-31445.html)

Pages: 1 2


How can i send email via form in CI ? - El Forum - 06-19-2010

[eluser]dhaulagiri[/eluser]
I only get email title doing this, how can i get user input message in mail as well ?
pls help

view file
Code:
<?php echo form_open_multipart('quickmail/send_quickly')?>
&lt;input type="text" value="subject" name="subject" /&gt;&lt;br /> <br />
&lt;textarea name="message" rows="15" cols="60" /&gt;&lt;/textarea><br /><br />
&lt;input type="file" name="file_name" /&gt;&lt;br /><br />
&lt;input type="submit" value="Send quick mail" /&gt;
&lt;?php echo form_close()?&gt;

controller file
Code:
function send_quickly()
    {

        
        //get data
      $subject = $this->input->post('subject');
      $email = 'me@gmail.com';
      $message = $this->input->post('message');
        
        
        $this->load->library('email');
        $this->email->set_newline("\r\n");

        $this->email->from('info@imm.co.uk', 'mycc');
        $this->email->to($email);
        $this->email->subject($subject);
        $this->email->message($message);
        
        $path = '';
        $file_name = $path;
        
        $this->email->attach($file_name);
        
        if($this->email->send()){
            $this->confirm_sent();
        }else{
            echo "Message not sent";
        }
    }



How can i send email via form in CI ? - El Forum - 06-19-2010

[eluser]erik.brannstrom[/eluser]
What is your problem exactly? Is the mail not sent, or is it just malformed? If you are having problems, please add this line at the end of the method and show us the output.

Code:
echo $this->email->print_debugger();



How can i send email via form in CI ? - El Forum - 06-19-2010

[eluser]siubie[/eluser]
i have same problem here i send the email but never found in recipen email not in spam not in anywhere any suggestion ?


How can i send email via form in CI ? - El Forum - 06-19-2010

[eluser]erik.brannstrom[/eluser]
siubie: Please see my previous post regarding the debugger.


How can i send email via form in CI ? - El Forum - 06-19-2010

[eluser]siubie[/eluser]
thx erik trying debugger now Smile


How can i send email via form in CI ? - El Forum - 06-20-2010

[eluser]dhaulagiri[/eluser]
The problem is, message body is not received in mail when i assigned it in variable ($this->email->message($message); but it's ok when i do $this->email->message('this is test mai'); Am i missing something when assigning variable ?


How can i send email via form in CI ? - El Forum - 06-20-2010

[eluser]erik.brannstrom[/eluser]
Backtrack. So you receive an email, though with the content missing? Use the debugger to see what is actually sent. Echo the message variable before that. Echo the post variable before that. Do all this and you'll see where things go wrong.

I'm gonna go out on a limb here and guess that you omitted form validation from your method, and if so my guess is that that's where your problem lies. In any case though, please do all the above to make sure and tell us how it goes.


How can i send email via form in CI ? - El Forum - 06-20-2010

[eluser]dhaulagiri[/eluser]
It says

Mime-Version: 1.0
Content-Type: multipart/mixed; boundary="B_ATC_4c1e1c3441d48"

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

--B_ATC_4c1e1c3441d48
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
=?utf-8?Q?subject?=


How can i send email via form in CI ? - El Forum - 06-20-2010

[eluser]dhaulagiri[/eluser]
OK i am able to send message now,

any suggestion for sending attachments via mail ?


How can i send email via form in CI ? - El Forum - 06-20-2010

[eluser]erik.brannstrom[/eluser]
Yes, please see the user guide. It tells you how to attach files.