Welcome Guest, Not a member yet? Register   Sign In
Please help me to send mail this way
#1

[eluser]dhaulagiri[/eluser]
Hi all I want to send all the variables and strings inside the opening and closing of form tag in email. Can anybody give me a breif example what to write in a controller ?

my view file is like this
Code:
<?php echo form_open('latest/send_email')?>

<h2>User Information</h2>
<p> example: your user info is as following </P>
    Title: &lt;?php echo $data['user_title']; ?&gt;
    <br />
    First Name: &lt;?php echo $data['first_name'];?&gt;


&lt;textarea rows="10" cols="125"&gt;This is another example string&lt;/textarea&gt;
    <br />
    &lt;input type="submit" value="send mail" /&gt;
    
    &lt;?php echo form_close()?&gt;
#2

[eluser]Flemming[/eluser]
you can load a view into a variable like this:

Code:
$data['name'] = 'my name';
$data['message'] = 'hello world';

$email_content = $this->load->view('email_view',$data,TRUE);

now you can send your email, and use $email_content as the message:

Code:
$this->email->message($email_content);

your email_view.php would look like this:

Code:
Dear $name,
$message

hope that helps?
#3

[eluser]dhaulagiri[/eluser]
Thank you so much,

it was successful. However, all the html is being sent as email including stylesheet and eveything, is it possible to parse html ?
#4

[eluser]Flemming[/eluser]
have you set:

$config['mailtype'] = 'html'; ?

if you want to send HTML email you should write a view that contains HTML specially written for an email and it shouldn't use CSS
#5

[eluser]dhaulagiri[/eluser]
i did create email.php in config folder and wrote this


Code:
&lt;?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

$config[‘mailtype’] = ‘html’;

and added this in controller
Code:
$this->load->library('email', $config);

still problem exists pls help. Please enlight me how to send HTML email.
#6

[eluser]Flemming[/eluser]
what does your view look like ?
#7

[eluser]dhaulagiri[/eluser]
view file is as follows

Code:
&lt;style&gt;

#form_content2 {
border:solid 5px #c6cfe1;
margin: 8px;
padding: 8px;
overflow: hidden;
}


.mid{
float:left;
width:50%;
clear:left:
}

&lt;/style&gt;

<h1>&lt;?php echo "Send ".  $title . " to ". $data['first_name'] ; ?&gt;</h1>

&lt;?php echo form_open('new/email')?&gt;
<div id="form_content2">
<div id="form_content3" class="mid">
<h2>User Information</h2>
    Title: &lt;?php echo $data['title']; ?&gt;
    <br />
    First Name: &lt;?php echo $data['first_name'];?&gt;
    <br />
    Last Name: &lt;?php echo $data['last_name'];?&gt;    
    <br />
    Street: &lt;?php echo $data['Street_name'];?&gt;
    <br />
    Town: &lt;?php echo $data['town'];?&gt;    
    <br />
    &lt;?php echo $data['city'];?&gt;
    <br />
    </div>
    
    &lt;!-- texarea begins for notes --&gt;
    <br />
    <h2>Notes: example included in the email.</h2>
    &lt;textarea rows="10" cols="125"&gt;
    09/06/2010: Offer
    &lt;/textarea&gt;
    <br />
    &lt;input type="submit" value="send offer" /&gt;
    
    &lt;?php echo form_close()?&gt;
#8

[eluser]Flemming[/eluser]
that's a form? Sorry, am a little confused about what you're trying to do!

I thought you wanted to send an email with $data in it?

could you explain your process simply?
#9

[eluser]Ivar89[/eluser]
Thanks @flemming, I need A way to sent more in a message to, didn't know you could message a view in a varTongue
thanks^^, works like a charm.
#10

[eluser]Ivar89[/eluser]
in system folder->libraries there is a file called Email.php
change mailtyp te HTMl there
then:
Code:
$this->load->library('Email');
in you controller(or in autoload.php)

from the look of your view I see that name and such is already posted from an other page?
any you should write in controller(what flamming wrote:
Code:
$data['first_name'] = '$_POST('first_name;)';
$data['last_name'] = '$_POST('last_name')';
$data['message'] = '$_POST('message')';
$data['somethingelse'] = '$_POST('somethingelse')';
$email_content = $this->load->view('email_view',$data,TRUE);

$this->email->from($_POST['first_name'], $_POST['last_name']);
$this->email->to('[email protected]');

$this->email->subject('something....');
$this->email->message($email_content);
$this->email->send();
$this->load->view('yourview', $data);
email view:
Code:
$first_name last_name,
$message

EDIT: >>>this is without form_validation though<<<




Theme © iAndrew 2016 - Forum software by © MyBB