Welcome Guest, Not a member yet? Register   Sign In
Email Attachment Problem
#1

[eluser]Synchy[/eluser]
Good evening,

I'm having a problem with attaching files to an e-mail using the CI email class. The attachment is a pdf-file. The problem is that the e-mail sends perfectly including the attachment to my gmail address, but the e-mail message isn't included. For my hotmail address the problem is the opposite, the message is included but the attachment isn't, instead it places some random code in the message body.

Code:
--B_ATC_4d3daddb2961c
Content-type: application/pdf;
name="test.pdf"
Content-Disposition: attachment;
Content-Transfer-Encoding: base64

JVBERi0xLjQKJcOkw7zDtsOfCjIgMCBvYmoKPDwvTGVuZ3RoIDMgMCBSL0ZpbHRlci9GbGF0ZURl
Y29kZT4+CnN0cmVhbQp4nJVUS2vjMBC+61fMuWB3Rm+BMSRNAru3gKGHZU/p69B0aS/793dmJMfO

This is the code placed in the hotmail e-mail, it's a lot longer but I won't bore you with even more random characters.

This would be the code used for sending an e-mail, the path to the file etc is correct because as I said before my gmail address received the attachment perfectly.

Code:
function send_order_mail($to, $attach) {
$config['wordwrap'] = FALSE;
$config['mailtype'] = 'text';

$this->email->initialize($config);
$this->email->from('[email protected]', 'Helios Studio');
$this->email->to($to);
//$this->email->bcc('[email protected]');

$this->email->attach($attach);
$this->email->subject('Bestelling');
$this->email->message('Dit is je factuur');

$this->email->send();
}

I hope someone has the solution to my problem, kind regards.
#2

[eluser]InsiteFX[/eluser]
What does the $attach file path look like?

Also you should specify the mail protocol.

If it is SMTP then you need to specify those parameters also.

InsiteFX
#3

[eluser]Synchy[/eluser]
Everything is happening on my localhost (xampp), I've set my php.ini settings so it uses the SMTP server of my ISP. But when I change the protocol to 'smtp' or even 'sendmail' then it doesn't send e-mails anymore.

The path in $attach should be correct because my gmail does receive the correct attachment, the path is "docs/bestelling_70.pdf".
#4

[eluser]InsiteFX[/eluser]
The path should have a / when it is built.

Code:
/docs/bestelling_70.pdf

Check when $attach is built that the path is like above.

InsiteFX
#5

[eluser]Synchy[/eluser]
When I put a "/" before the path it just sends empty e-mails, to my gmail as well.

But which of the 3 protocols has to be used to use attachments? Because currently it's on the default, being 'mail'. And might it be that I just can't run the protocol 'smtp' or 'sendmail' on my xampp-server and that it might work when I deploy it on a proper webhost?
#6

[eluser]InsiteFX[/eluser]
Try using the sendmail protocol and see if that will work.

InsiteFX
#7

[eluser]Synchy[/eluser]
It says my server probably isn't configured enough/correctly to use the 'sendmail' protocol. I'm using xampp on my localhost.
#8

[eluser]InsiteFX[/eluser]
After your email send try this.

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

I use this tool for email on Windows 7 Pro 64-bit.

Email testing tool

InsiteFX
#9

[eluser]Synchy[/eluser]
Then I'm getting the following error:

Code:
Exit status code: 1
Unable to open a socket to Sendmail. Please check settings.
Unable to send email using PHP Sendmail. Your server might
not be configured to send mail using this method.
User-Agent: CodeIgniter
Date: Wed, 26 Jan 2011 15:59:47 +0100
From: "Helios Studio"
Return-Path:
To: [email protected]
Subject: =?utf-8?Q?Bestelling?=
Reply-To: "[email protected]"
X-Sender: [email protected]
X-Mailer: CodeIgniter
X-Priority: 3 (Normal)
Message-ID: <[email protected]>
Mime-Version: 1.0


Content-Type: multipart/mixed; boundary="B_ATC_4d4036e3c6dc0"

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

--B_ATC_4d4036e3c6dc0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

Dit is je factuur

--B_ATC_4d4036e3c6dc0
Content-type: application/pdf; name="bestelling_110.pdf"
Content-Disposition: attachment;
Content-Transfer-Encoding: base64

JVBERi0xLjYKJeTjz9IKMSAwIG9iagpbL1BERi9JbWFnZUIvSW1hZ2VDL0ltYWdlSS9UZXh0XQpl
bmRvYmoKNCAwIG9iago8PC9MZW5ndGggNSAwIFIKL0ZpbHRlci9GbGF0ZURlY29kZQo+PgpzdHJl

Like in my first post the list of random characters at the end is a lot longer.
#10

[eluser]InsiteFX[/eluser]
Use SMTP then if that is what works!

But it looks like your are having an encoding type problem!

trying changing the encoding to iso-8859-1

InsiteFX




Theme © iAndrew 2016 - Forum software by © MyBB