473,408 Members | 2,888 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,408 software developers and data experts.

email attachment in php

7
Help...I am trying to integrate a way in my code to process a form , send an email containg form info, and if file is uploaded, place it as an attachment on the email being sent, without losing the other form data contained in the message body. I have seen codes on how to do it, but am wondering if it's possible to adjust the current codes to handle this function.

Any info would help...Thanks
Feb 1 '07 #1
8 3726
ronverdonk
4,258 Expert 4TB
What 'current codes' are you talking about? If we can't see any of it, how do you expect us to evaluate it and give an answer?

Ronald :cool:
Feb 1 '07 #2
LANTEK
7
Sorry forgot to attach code that i am working with for the form...

<?
///////////////////////////////////////////////////////////////////
// PERFECT //
///////////////////////////////////////////////////////////////////

// Configuration Settings
$SendFrom = "Sales <sales@lantekonline.com>";
$SendTo = "ayob@lantekonline.com";
$SubjectLine = "Asset Inventory Evaluation ";
$ThanksURL = "Asset_thankyou.htm"; //confirmation page
$Divider = "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~";

// Build Message Body from Web Form Input
$MsgBody = @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\r\n$Divider\r\n";
foreach ($_POST as $Field=>$Value)
$MsgBody .= "$Field: $Value\r\n";
$MsgBody .= "$Divider\r\n" . $_SERVER["HTTP_USER_AGENT"] . "\r\n";
$MsgBody = htmlspecialchars($MsgBody); //make content safe

// Send E-Mail and Direct Browser to Confirmation Page
mail($SendTo, $SubjectLine, $MsgBody, "From: $SendFrom");



header("Location: $ThanksURL");
?>
Feb 2 '07 #3
Motoma
3,237 Expert 2GB
Help...I am trying to integrate a way in my code to process a form , send an email containg form info, and if file is uploaded, place it as an attachment on the email being sent, without losing the other form data contained in the message body. I have seen codes on how to do it, but am wondering if it's possible to adjust the current codes to handle this function.

Any info would help...Thanks
It is possible to do this. What are you having difficulties with?
Feb 2 '07 #4
LANTEK
7
I can upload the file (not sure where it goes) but it doesn't come as an attachment on the email from the form....
Feb 2 '07 #5
Motoma
3,237 Expert 2GB
Here is an example of sending attachments in an email from the PHP.net board:
[PHP]
<?php

function mxcl_mail( $subject, $message )
{
ob_start();
print_r( $GLOBALS );
$teh_globals = chunk_split( base64_encode( ob_get_clean() ) ); // base 64 encode

$date = date( 'r' );
$phpversion = phpversion();
$boundary = md5( time() );
$filename = '$GLOBALS.txt';


$headers = <<<END
From: $_SERVER[PHP_SELF] <php@$_SERVER[SERVER_NAME]>
Date: $date
X-Mailer: PHP v$phpversion
MIME-Version: 1.0
Content-Type: multipart/related; boundary="$boundary"
END;

$message = <<<END
--$boundary
Content-Type: text/plain; charset="iso-9959-1"
Content-Transfer-Encoding: 7bit

$message

--$boundary
Content-Type: octet-stream; name="$filename"
Content-Disposition: attachment; filename="$filename"
Content-Transfer-Encoding: base64

$teh_globals

--$boundary--

END;

mail( 'webmaster@example.com', $subject, $message, $headers );
}

?>
[/PHP]
Instead, you will need to set the part inside the boundry to the file body, base64 encoded.
Feb 2 '07 #6
LANTEK
7
I think I'm confused...can I insert this into my existing code?
Feb 2 '07 #7
Motoma
3,237 Expert 2GB
I think I'm confused...can I insert this into my existing code?
No, you cannot.
But it is a great example that is quite easily modified for you use.
Feb 2 '07 #8
study about php mailer it could help u
http://phpmailer.sourceforge.net/tutorial.html
Feb 15 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Wald | last post by:
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...
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
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.