473,372 Members | 1,055 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,372 software developers and data experts.

Email attachment

Hello group,

I've got a script here that sends emails with an attachment to
an email address that is retrieved from an html form. The
email sending code is include below.

The problem: when sending the email to certain email servers,
the attachment section of the email gets removed and I end up
with an attachment of zero kb. Other servers do accept the
attachment as expected.

This might seem to be server-related, but when I send a
regular email with attachment (not with the php code) to the
problem servers, nothing irregular happens and the attachment
stays intact. So the problem must be with the email generating
code, but I don't seem to be able to isolate it...

Anyone who can shed a light on this?

Thanks in advance,
Wald
-- email sending code ---------------------------------------
function sendmsg($to, $subject, $msgtext, $from, $file, $type)
{
$fp = fopen($file,"rb");
$fcontent = fread($fp ,filesize($file));
fclose($fp);
$content = chunk_split(base64_encode($fcontent));
$sep = strtoupper(md5(uniqid(time())));
$name = basename($file);
$header = "From: $from\nReply-To: $from\n";
$header .= "MIME-Version: 1.0\n";
$header .= "Content-Type: multipart/mixed; boundary=$sep
\n";
$body .= "--$sep\n";
$body .= "Content-Type: text/plain\n";
$body .= "Content-Transfer-Encoding: 8bit\n\n";
$body .= "$msgtext\n";
$body .= "--$sep\n";
$body .= "Content-Type: $type; name=\"$file\"\n";
$body .= "Content-Transfer-Encoding: base64\n";
$body .= "Content-Disposition: attachment; filename=
\"$file
\"\n";
$body .= "$content\n";
$body .= "--$sep--";
if (mail($to, $subject, $body, $header)) {
return true;
} else {
return false;
}
}

Jul 16 '05 #1
4 26652
Wald <arnout.standaert@n-o_s-p-a-m.cit.kuleuven.ac.be> wrote:
Hello group,

I've got a script here that sends emails with an attachment to
an email address that is retrieved from an html form. The
email sending code is include below.

The problem: when sending the email to certain email servers,
the attachment section of the email gets removed and I end up
with an attachment of zero kb. Other servers do accept the
attachment as expected.


Just to let you know guys, even the smallest of clues might help
here!

Thanks,
Wald
Jul 16 '05 #2
On Tue, 08 Jul 2003 14:58:17 +0000, Wald wrote:
Wald <arnout.standaert@n-o_s-p-a-m.cit.kuleuven.ac.be> wrote:
Hello group,

I've got a script here that sends emails with an attachment to an email
address that is retrieved from an html form. The email sending code is
include below.

The problem: when sending the email to certain email servers, the
attachment section of the email gets removed and I end up with an
attachment of zero kb. Other servers do accept the attachment as
expected.


Just to let you know guys, even the smallest of clues might help here!

Thanks,
Wald


Try copying the headers off the email that works. Copy them *exactly*.

Paste into PHP script.

Test email.

later...
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #3
"Jeffrey Silverman" <je*****@jhu.edu> wrote:
On Tue, 08 Jul 2003 14:58:17 +0000, Wald wrote:
Wald <arnout.standaert@n-o_s-p-a-m.cit.kuleuven.ac.be> wrote:
I've got a script here that sends emails with an attachment to
an email address that is retrieved from an html form. The
email sending code is include below.

The problem: when sending the email to certain email servers,
the attachment section of the email gets removed and I end up
with an attachment of zero kb. Other servers do accept the
attachment as expected.


Try copying the headers off the email that works. Copy them
*exactly*.

Paste into PHP script.

Test email.


Argh. This ended up being a problem with line endings. CRLF endings
are apparently needed after MIME separator lines, I only provided
one single \n.

Anyway, thanks for the moral support ;-)

Wald
Jul 16 '05 #4
On Wed, 09 Jul 2003 13:11:38 +0000, Wald wrote:
<snip!>
Argh. This ended up being a problem with line endings. CRLF endings are
apparently needed after MIME separator lines, I only provided one single
\n.

Anyway, thanks for the moral support ;-)

Wald


And thanks for describing what the problem turned out to be. Too many
threads end without reconciliation...
--
Jeffrey D. Silverman | jeffrey AT jhu DOT edu
Johns Hopkins University | Baltimore, MD
Website | http://www.wse.jhu.edu/newtnotes/

Jul 16 '05 #5

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

Similar topics

1
by: abracad | last post by:
I'd like to add a form that will email a file attachment to me. Can anyone recommend a decent free script? Thanks
4
by: Paul Schmidt | last post by:
Dear list: I am new to python, and I am trying to figure out the short answer on something. I want to open a POP3 mailbox, read the enclosed mail using the POP3 module, , and then process it...
2
by: Martin Körner | last post by:
Hi NG, I am using email module for creating mails with attachment (and then sending via smtplib). If the name of the attachment file is longer than about 60 characters the filename is wrapped...
5
by: morphex | last post by:
Hi, I have an email that's in the utf-8 encoding, and I'm getting this error message when I try to send it using smtplib: * Module smtplib, line 688, in sendmail * Module smtplib, line 485,...
3
by: =?Utf-8?B?SHVnaA==?= | last post by:
Hi There, I use follow code to send email inside VB.NET 2005. It does not work well. Error message of "Failure sending email" would occue. However, email was sent out sometimes. I am confused...
7
by: erikcw | last post by:
Hi all, I'm trying to extract zip file (containing an xml file) from an email so I can process it. But I'm running up against some brick walls. I've been googling and reading all afternoon, and...
7
by: Paridevi | last post by:
Hai , i want to send email in .Net Using OutLook Express,My Project is Web Application using vb.Net 2003 with SQL Server 2000.I have searched a lot in Google, but ican't get any...
3
by: jambonjamasb | last post by:
Hi I have two tables: email_tbl Data_table Data table is is used to create a Form Data_form
0
by: tourerukcom | last post by:
Hi i wonder if any one can help. I have script that that sends a email with mulitple attachments. It seems to work fine as i get the email with the attachments on. But other people i send it to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.