CodeIgniter Forums
my email has no message and attachment - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: my email has no message and attachment (/thread-53176.html)



my email has no message and attachment - El Forum - 07-13-2012

[eluser]sushi[/eluser]
Hello every body,
I run into a sending email issue. My recipient can receive the email, but only the upper part of the mail, from, to and subject.
There is no message, no attachment at all.

However, it was not the case before, at the beginning of my running test, everybody can receive a whole page of email. Suddenly, recipients can only get the from, to and the subject parts but no message or attachment!

I wonder whats happening? I am working on the same computer and the same localhost apache setup. PHP Version 5.3.8. Can any one of you help.

Here is my config.php and below that is my emial send out function, please take a look and help.

$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.googlemail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = '[email protected]';
$config['smtp_pass'] = '3456';
$config['mailtype'] = 'html';
$config['charset'] = 'iso-8859-1';

public function send(){

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

$this->email->from('[email protected]', 'Art H');
$this->email->to([email protected]);
$this->email->subject('A short subject');
$this->email->message('Message for you today');
$path = $this->config->item('server_root');
$file = $path . '/day1/attachments/somenote.txt';
$this->email->attach($file);

if($this->email->send())
{


$this->load->view('signup_confirmation_view');
}

else
{
show_error($this->email->print_debugger());
}
}

Sushi


my email has no message and attachment - El Forum - 07-13-2012

[eluser]InsiteFX[/eluser]
You $config parameters should be in the function sending the email.



my email has no message and attachment - El Forum - 07-13-2012

[eluser]sushi[/eluser]
InsiteFX,

Thanks for your suggestion. I did that but it makes no big different.

It seems that it is the attach cause the trouble. When I REM out those 2lines of attachment than I have an email with message.

And I tried to go through my own ISP's smtp, the result were the same. So I think might it be something within codeigniter framework




my email has no message and attachment - El Forum - 07-13-2012

[eluser]InsiteFX[/eluser]
Your assigning $path but it does not show in your code.
Code:
$file = $path . '/day1/attachments/somenote.txt';
// maybe it should be, you do not use a full url.
$file = '/day1/attachments/somenote.txt';

Check and see if your getting any errors.
Code:
$this->email->print_debugger();



my email has no message and attachment - El Forum - 07-14-2012

[eluser]sushi[/eluser]
Thanks again insiteFX, the issue has been solved by accident.

As we can see,
$path = $this->config->item(‘server_root’); [defined in the config.php]

The 'server_root' really gives you up to the server's root! It is so wonderful.

And do you know what? My project is in a project folder within root, and day1 is within that project folder, so the following snippet
$file = $path . ‘/day1/attachments/somenote.txt’; is missing a folder in front of day1!!!!

This is why I said the email suddenly doesn't work properly, because before I moved email file into a project folder it is bared under the root!

Any way there is not an issue, codes were perfect.

Thanks a lot for your help.