Jak korzystać z funkcji e-mail-> załączania?Kod Zapalnik -> dołącz wiadomość e-mail
Nie mogę określić, co się dzieje, ponieważ po umieszczeniu kodu na adres e-mail-> załączyć komunikat jest pusty (treść wiadomości) i nie ma załącznika.
jeśli usunąć tę linię kodu, wszystko wróci do normy ..
dziękuję
mój kontroler (sendmail.php)
<?php
class Sendmail extends Controller {
function __construct() {
parent::Controller();
$this->load->library('email');
$this->load->helper('url');
$this->load->helper('form');
$this->load->library('validation');
}
function index() {
$info = array (
'nome' => $this->input->post('nome'),
'mail' => $this->input->post('email'),
'motivo' => $this->input->post('motivo'),
'mensagem' => $this->input->post('mensagem'),
'anexo' => $this->input->post('upload'),
);
$this->load->library('email');
$this->email->set_newline('\r\n');
$this->email->clear();
$this->email->from($info['mail'], $info['nome']);
$this->email->to('[email protected]');
/* $this->email->cc(''); # não é preciso */
$this->email->subject($info['motivo']);
$this->email->message($info['mensagem']);
$this->email->attach($info['anexo']);
if ($this->email->send()) {
echo 'sent';
}
else {
$this->load->view('formulario');
# show_error($this->email->print_debugger());
}
}
}
?>
mój widok (formulario.php)
<?php
echo form_open_multipart('davidslv/index.php/sendmail');
?>
<label for="nome">nome</label>
<input type="text" name="nome" id="nome" required />
<label for="email">email</label>
<input type="text" name="email" id="email" required />
<label for="assunto">assunto</label>
<select name="motivo">
<option value="motivo1">motivo1</option>
<option value="motivo2">motivo2</option>
<option value="motivo3">motivo3</option>
</select>
<p> <label for="mensagem">mensagem</label>
<textarea name="mensagem" id="mensagem" rows="8" cols="30" required></textarea>
</p>
<label for="upload">documento</label>
<input type="file" id="upload" name="upload" size="18"/>
<input type="submit" id="enviar" name="enviar" value="Enviar!" />
</form>
Trzeba wyjaśnić, co dokładnie jesteś próbujesz załączyć plik JPG/PDF, czy plik jest przesyłany przez użytkownika? Czy znajduje się w katalogu takim jak /home/bob/photo.jpg? etc ... potrzebuję więcej szczegółów .. – Jakub
również, jak o opublikowaniu kodu, który do tej pory widzieliśmy, co potencjalnie robi źle. –
Witam, zredagowałem mój post, aby było bardziej zrozumiałe. Zamysłem jest, aby każdy użytkownik mógł wysłać mi e-mail, ale w jakiś sposób ciało (mensagem) jest puste i nie ma załącznika – Davidslv