473,405 Members | 2,171 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

mail() and pdf attachment

I am trying to send a pdf file as an attachment with the mail()
function. Unfortunately, the pdf file does not show up as an
attachment. I get its coding as text along with this:

MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="==Multipart_Boundary_x893cd7b85e299baba9 cd7ab913384411x"

--==Multipart_Boundary_x893cd7b85e299baba9cd7ab91338 4411x
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

this is the message

--==Multipart_Boundary_x893cd7b85e299baba9cd7ab91338 4411x
Content-Type: application/pdf;
name="Test file for jmail.pdf"
Content-Disposition: attachment;
filename="Test file for jmail.pdf"
Content-Transfer-Encoding: base64

JVBERi0xLjQKJcfsj6IKNSAwIG9iago8PC9MZW5ndGggNiAwIF IvRmlsdGVyIC9GbGF0ZURlY29k
ZT4+

.... a lot omitted

wMDU4NiAwMDAwMCBuIAowMDAwMDAxMDc1IDAw
MDAwIG4gCjAwMDAwMDA3ODAgMDAwMDAgbiAKMDAwMDAwODg3MC AwMDAwMCBuIAp0cmFpbGVyCjw8
IC9TaXplIDE1IC9Sb290IDEgMCBSIC9JbmZvIDIgMCBSCi9JRC BbPDhCNzc0RDNGRkNGRDI2RjIw
M0Q0REMyMjk5NjY4NTRDPjw4Qjc3NEQzRkZDRkQyNkYyMDNENE RDMjI5OTY2ODU0Qz5dCj4+CnN0
YXJ0eHJlZgoxMDQ1MwolJUVPRgo=
--==Multipart_Boundary_x893cd7b85e299baba9cd7ab91338 4411x--

Can anyone tell me what is wrong?

Regards,

Jan Nordgreen

Oct 4 '07 #1
2 19790
Hi Michael,

Thank you for answering!

$fromname = $_SESSION['myname'];
$fromaddress = $_SESSION['myemailaddress'];
$headers = "From: \"".$fromname."\" <".$fromaddress.">\n";
$bcc = $_SESSION['myemailaddress'];
$headers .= 'Bcc: '.$bcc. "\n";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

This was my offending code!

I had too many line shifts (\n) in $headers.

I changed the last line to:

$headers .= "MIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

and then it worked!

Regards,

Jan Nordgreen
Oct 5 '07 #2
On Oct 5, 12:45 pm, damezumari <jannordgr...@gmail.comwrote:
Hi Michael,

Thank you for answering!

$fromname = $_SESSION['myname'];
$fromaddress = $_SESSION['myemailaddress'];
$headers = "From: \"".$fromname."\" <".$fromaddress.">\n";
$bcc = $_SESSION['myemailaddress'];
$headers .= 'Bcc: '.$bcc. "\n";
$headers .= "\nMIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

This was my offending code!

I had too many line shifts (\n) in $headers.

I changed the last line to:

$headers .= "MIME-Version: 1.0\n" .
"Content-Type: multipart/mixed;\n" .
" boundary=\"{$mime_boundary}\"";

and then it worked!

Regards,

Jan Nordgreen
Ahh that explains a lot.
I'm glad to hear you got it to work ;-)

//Michael
Oct 5 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: PeterR | last post by:
I've spent weeks trying to write a function that is simple to use for sending emails with attachments, but I my programming skills are not that advanced. I've noticed a few postings in these...
2
by: knoak | last post by:
Hi there, I've found a script at these great Google fora. a script to send emails with attachments. The script is below this message, name etc. aren't mine, but from the original post. My...
0
by: imre.adam | last post by:
The original message was received at Wed, 2 Mar 2005 20:06:59 +0100 from 87.26.243.56 ----- The following addresses had permanent fatal errors ----- <python-list@python.org> ----- Transcript...
1
by: theWizard1 | last post by:
The following sends my email, but the attachment is empty. The attachment should contain the data that is in the string that was created from the xmlReader. I have a stored procedure written...
6
by: rekaeps | last post by:
We are developing an ASP.NET 2.0 (C#) application, and I'm having troubles sending e-mail from the server when accessing the web site from a separate client computer. Also, in the same scenario,...
1
by: William Connery | last post by:
Hi, I have a small python program with e-mail capabilities that I have pieced together from code snippets found on the internet. The program uses the smtplib module to successfully send an...
2
by: eng.sharif | last post by:
hi group how i can send mail and attachement in php with "mail function " $s = mail($to,$subject,$cont, $headers); can anyone help
2
by: Ruud | last post by:
Just before leaving for a holiday my collegue modified this script. Now it won't send any body text (The data filled in on the form) and in an error condition it won't send any attachments either....
1
by: nukephp | last post by:
Hello Guys would you know about php email with his attachment Working on linux platform................................................... The code as below: mail.php <?php //define the...
1
by: maxxxxel | last post by:
Hi Can anyone help me with some asp code , I changed the code to use CDO.message instead of the old cdont.sys to send mail from a ASP webpage which works fine. Our problem is that when we send...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.