473,756 Members | 2,721 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Mail from PHP

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.

Because I don't understand PHP I cannot find the error. Who is willing
to help?

regards Ruud
Current PHP script:

<?php

$emailadres_rea cties = "st**********@m ysite.nl";
$emailadres_log bestanden = "st**********@m ysite.nl";

/*
* Class mime_mail
*/

class mime_mail
{
var $parts;
var $to;
var $from;
var $headers;
var $subject;
var $body;
/*
* void mime_mail()
* class constructor
*/
function mime_mail()
{
$this->parts = array();
$this->to = "";
$this->from = "";
$this->subject = "Test";
$this->body = "Body tekst";
$this->headers = "";
}

/*
* void add_attachment( string message, [string name], [string
ctype])
* Add an attachment to the mail object
*/
function add_attachment( $message, $name = "", $ctype =
"applicatio n/octet-stream")
{
$this->parts[] = array (
"ctype" =$ctype,
"message" =$message,
"encode" =$encode,
"name" =$name
);
}

/*
* void build_message(a rray part=
* Build message parts of an multipart mail
*/
function build_message($ part)
{
$message = $part[ "message"];
$message = chunk_split(bas e64_encode($mes sage));
$encoding = "base64";
return "Content-Type: ".$part[ "ctype"].
($part[ "name"]? "; name = \"".$part[ "name"]. "\"" : "").
"\nContent-Transfer-Encoding: $encoding\n\n$m essage\n";
}

/*
* void build_multipart ()
* Build a multipart mail
*/
function build_multipart ()
{
$boundary = "b".md5(uniqid( time()));
$multipart = "Content-Type: multipart/mixed; boundary = $boundary\n
\nThis is a MIME
encoded message.\n\n--$boundary";

for($i = sizeof($this->parts)-1; $i >= 0; $i--)
{
$multipart .= "\n".$this->build_message( $this->parts[$i]). "--
$boundary";
}
return $multipart.= "--\n";
}

/*
* void send()
* Send the mail (last class-function to be called)
*/
function send()
{
$mime = "";
if (!empty($this->from))
$mime .= "From: ".$this->from. "\n";
if (!empty($this->headers))
$mime .= $this->headers. "\n";

if (!empty($this->body))
$this->add_attachment ($this->body, "", "text/plain");
$mime .= "MIME-Version: 1.0\n".$this->build_multipar t();
mail($this->to, $this->subject, "", $mime);
}
}; // end of class
// begin sessie
session_start() ;

// tel aantal variabelen
$numElements = count($_POST);

if($numElements ==48)
{
$mail = new mime_mail();

$mail->from = "no*****@mysite .nl";
$mail->from = "st**********@m ysite.nl";

$mail->headers = "Errors-To: in**@mysite.nl";
$mail->to = $emailadres_rea cties;

$mail->subject = "aanmelding via sterktemeter";
$tmp = array_reverse($ _POST);
$tmp = array_slice($tm p,15);
$_POST = array_reverse($ tmp);
$_POST = array_reverse($ _POST);

$werknemer = array_slice($_P OST, 0, 8);
$werkgever = array_slice($_P OST, 8, 8);
$aanmelding = array_slice($_P OST, 16, 1);
$arbo = array_slice($_P OST, 17, 9);
$factuur = array_slice($_P OST, 26, 7);

$mail->body = $mail->body."\n\n".im plode("\n", $werknemer);
$mail->body = $mail->body."\n\n".im plode("\n", $werkgever);
$mail->body = $mail->body."\n\n".im plode("\n", $aanmelding);
$mail->body = $mail->body."\n\n".im plode("\n", $rabo);
$mail->body = $mail->body."\n\n".im plode("\n", $factuur);

$mail->send();

}
else
{
$mail = new mime_mail();
$mail->from = "st**********@m ysite.nl";
$mail->headers = "Errors-To: sp**@mysite.nl";
$mail->to = $emailadres_log bestanden;
$mail->subject = "logbestand sterktemeter";
$mail->body = "- logbestanden van de sterktemeter in bijgesloten XML
bestand -";

//verwerk ontvangen variabelen van Flash tot XML bestand
$data = $data."<UNIEKE_ ID>".$subject.S ession_ID()."</UNIEKE_ID>
\n";
$data = $data."<IP_ADRE S>".$REMOTE_ADD R."</IP_ADRES>\n";
$data = $data."<DATUM>" .date("d/m/Y")."</DATUM>\n";
$data = $data."<TIJD>". date("H:m")."</TIJD>\n";
$data = $data.implode(" \n", $_POST);

// maak een xml file met als bestandsnaam de sessie_id
$file = $subject.Sessio n_ID().".xml";

if (!$file_handle = fopen($file,"w" )) { echo "Cannot open
file"; }
if (!fwrite($file_ handle, $data)) { echo "Cannot write to
file"; }

// plaats attachment in variabele: $attachment
$attachment = fread(fopen($fi le, "r"), filesize($file) );
$mail->add_attachment ("$attachmen t", "rmlog.xml" , "txt/xml");

fclose($file_ha ndle);

// verwijder XML bestand van server
@unlink($file);

$mail->send();
}

?>

Aug 7 '07 #1
2 2673
Now it won't send any body text (The data filled in on the form)....

the call to mail() within the send method need to be changed to:

mail($this->to, $this->subject, $this->body, $mime);

...and in an error condition it won't send any attachments either.
can you describe this a little better?

Aug 7 '07 #2
On Aug 7, 5:29 pm, ELINTPimp <smsi...@gmail. comwrote:
Now it won't send any body text (The data filled in on the form)....

the call to mail() within the send method need to be changed to:

mail($this->to, $this->subject, $this->body, $mime);
...and in an error condition it won't send any attachments either.

can you describe this a little better?
I Changed "" into $this->body, there is still no body text
I changed "" onto "test" there is still no body text

the error condition:
If I understand the source correct it makes a rmlog.xml file when the
number of arguments is not equal to 48. I receive these mails but also
without a body or attachment

Aug 9 '07 #3

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

Similar topics

0
3294
by: Merijn Boom | last post by:
Hi there, I'm trying to create an html mail with embedded pictures in it. I run perl on Windows and Red Hat but I cannot get your module (Mail::Sender) to work. I'm just trying to run the examples. Below this message you'll find the perl example I'm using and the header of the e-mail. What am I doing wrong?
6
11184
by: DigitalRick | last post by:
I have been running CDONTS in my ASPpages to send emails to me sent from my guestbook. It had been working fine untill I upgraded to Server 2003 (I am also running Exchange 2003) all locally. I will include the code I originally used. I understand I should switch from CDONTS to CDO mail but after several sttempts I am finding a very hard time getting the new CDO mail to work properly. Any assistance with this would be greatly...
3
3272
by: Phil Mc | last post by:
Hi has anyone come accross the problem.... with referance to System.Web.Mail.MailMessage and System.Web.Mail.SmtpMail THIS WORKS FINE mail=new MailMessage(); mail.From = "W-MyPcName.mycompany.com"; mail.To=strTo; mail.Cc=strCC; mail.Bcc=strBCC;
3
3036
by: RN | last post by:
I am tired of sending mail from the built-in SMTP service for so many reasons (errors are nondescriptive in the event log, it doesn't let me control which IP address it sends from, and it identifies itself as the computer name which is not in domain.com format, triggering spam filter problems). Instead, I want to have my code send through an SMTP server of a company that we pay for mail service. But they require a username and password....
34
18269
by: antonyliu2002 | last post by:
I've set up the virtual smtp server on my IIS 5.1 like so: 1. Assign IP address to "All Unassigned", and listen to port 25. 2. Access Connection granted to "127.0.0.1". 3. Relay only allow "127.0.0.1". 4. Authentication: "Anonymous access" only. 5. Outbound connection listen to TCP 25. Besides,
4
2108
by: J Huntley Palmer | last post by:
How may I setup a proper HTML mail message with embedded href links using PHP, that follows all the MIME rules? Any examples or links would be appreciated. Thanks!
2
17487
by: clevrmnkey | last post by:
I've had nothing but trouble from the System.Net.Mail objects, but I finally need to make them work, and I can't for the life of me see what I'm doing wrong. I pared back my mail transaction to the bare minimum: System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient("<my mail server IP>", 25); smtp.Send("<one of my email addresses>", "<another of my email addresses>", "Hello", "World");
6
1986
by: cover | last post by:
I'm using PHP 5 at home w/Apache & MySQL on a test system where I write through a form to a database and also send an email to people on a drop down list. Purpose for this is an electronic log at work where an email goes out to let a person know an entry has been made with a copy of the text on that email. Works fine on my test system at home but not at work. I'm trying to remember which version of PHP I'm using there and I'm thinking...
2
5895
mikek12004
by: mikek12004 | last post by:
Before posting here I google it and saw ablut 30 pages for a solution so I pretty much excluded the obvious things. The code is <?php //now to send the mails to seller require("class.phpmailer.php"); $mail = new PHPMailer(); //$mail->IsSMTP(); // telling the class to use SMTP //$mail->Host = "smtp.example.com"; // SMTP server $from = "vasilis@emile.com"; $mail->From = $from;
0
9456
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9872
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9713
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8713
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.