Note that there are some explanatory texts on larger screens.

plurals
  1. POCode Igniter -> attach email
    primarykey
    data
    text
    <p>How do you use the email->attach function?</p> <p>I can't figure what is happen, cos when i put the code for email->attach the mesage came in blank(the mail body) and there is no attach.</p> <p>If i remove that code line, everything come back to normal..</p> <p>thank you</p> <p>my controller (sendmail.php)</p> <pre><code>&lt;?php class Sendmail extends Controller { function __construct() { parent::Controller(); $this-&gt;load-&gt;library('email'); $this-&gt;load-&gt;helper('url'); $this-&gt;load-&gt;helper('form'); $this-&gt;load-&gt;library('validation'); } function index() { $info = array ( 'nome' =&gt; $this-&gt;input-&gt;post('nome'), 'mail' =&gt; $this-&gt;input-&gt;post('email'), 'motivo' =&gt; $this-&gt;input-&gt;post('motivo'), 'mensagem' =&gt; $this-&gt;input-&gt;post('mensagem'), 'anexo' =&gt; $this-&gt;input-&gt;post('upload'), ); $this-&gt;load-&gt;library('email'); $this-&gt;email-&gt;set_newline('\r\n'); $this-&gt;email-&gt;clear(); $this-&gt;email-&gt;from($info['mail'], $info['nome']); $this-&gt;email-&gt;to('example@mai.com'); /* $this-&gt;email-&gt;cc(''); # não é preciso */ $this-&gt;email-&gt;subject($info['motivo']); $this-&gt;email-&gt;message($info['mensagem']); $this-&gt;email-&gt;attach($info['anexo']); if ($this-&gt;email-&gt;send() ) { echo 'sent'; } else { $this-&gt;load-&gt;view('formulario'); # show_error( $this-&gt;email-&gt;print_debugger() ); } } } ?&gt; </code></pre> <p>my view (formulario.php)</p> <pre><code> &lt;?php echo form_open_multipart('davidslv/index.php/sendmail'); ?&gt; &lt;label for="nome"&gt;nome&lt;/label&gt; &lt;input type="text" name="nome" id="nome" required /&gt; &lt;label for="email"&gt;email&lt;/label&gt; &lt;input type="text" name="email" id="email" required /&gt; &lt;label for="assunto"&gt;assunto&lt;/label&gt; &lt;select name="motivo"&gt; &lt;option value="motivo1"&gt;motivo1&lt;/option&gt; &lt;option value="motivo2"&gt;motivo2&lt;/option&gt; &lt;option value="motivo3"&gt;motivo3&lt;/option&gt; &lt;/select&gt; &lt;p&gt; &lt;label for="mensagem"&gt;mensagem&lt;/label&gt; &lt;textarea name="mensagem" id="mensagem" rows="8" cols="30" required&gt;&lt;/textarea&gt; &lt;/p&gt; &lt;label for="upload"&gt;documento&lt;/label&gt; &lt;input type="file" id="upload" name="upload" size="18"/&gt; &lt;input type="submit" id="enviar" name="enviar" value="Enviar!" /&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload