Page 1 of 1

Need PHP Email Script and Configuration

Posted: Mon Mar 23, 2009 7:49 am
by PatelNehal
Hello Everyone,
I am new PHP and want to write a script which will send email, so i download many ready to use script from net but all are not working. and giving some cool error which are :
***************************************************
maildemo.php
***************************************************
include("Mail.php");

$mimeBoundary = "boundary_" . md5(uniqid(time()));
$altBoundary = "boundaryAlt_" . md5(uniqid(time()));
$attBoundary = "boundaryAtt_" . md5(uniqid(time()));

$dir = './';
$zipfileName = 'test.zip';
$zipfile = 'test';

$headers = "From: yourmail<mail@yourdomain.com>rn";
$headers .= "MIME-version: 1.0rn";
$headers .= "Content-Type: multipart/mixed; boundary='$mimeBoundary'rn";

$body = "--" . $mimeBoundary . "rn";
$body .= "Content-Type: text/html; charset=iso-8859-1rn";
$body .= "Content-transfer-encoding: 7bitrnrn";
$body .= "<font color='red' face='verdana'>HTML Message</font>rnrn";

$body .= "--" . $mimeBoundary . "rn";
$body .= "Content-Type: application/x-zip-compressed; name=" . $zipfileName . ".gzrn";
$body .= "Content-transfer-encoding: base64rn";
$body .= "Content-Disposition: attachment; filename=" . $zipfileName . ".gzrnrn";

$file = file_get_contents($dir . $zipfile . ".zip");
$file = base64_encode($file);
$file = chunk_split($file);

$body .= $file . "rnrn";

$body .= "--" . $mimeBoundary . "--rn";


mail("patelnehal4u@yahoo.com", "A test zip mail",$body,$headers);

?>
***************************************************
Generated Error
***************************************************
Warning: include(Mail.php) [function.include]: failed to open stream: No such file or directory in C:\wamp\www\Temp\maildemo.php on line 11

Warning: include() [function.include]: Failed opening 'Mail.php' for inclusion (include_path='.;C:\php5\pear') in C:\wamp\www\Temp\maildemo.php on line 11

Warning: file_get_contents(./test.zip) [function.file-get-contents]: failed to open stream: No such file or directory in C:\wamp\www\Temp\maildemo.php on line 44

Warning: mail() [function.mail]: Failed to connect to mailserver at "mail.tesco.net" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\Temp\maildemo.php on line 53

***************************************************

is there anything i have to configure in my php.ini or setting up my SMTP server, and if yes how can i do that?

Re: Need PHP Email Script and Configuration

Posted: Wed Mar 25, 2009 3:05 am
by sujithtomy
Hello,

is Mail.php is the same directory ??

Re: Need PHP Email Script and Configuration

Posted: Fri Mar 27, 2009 12:14 am
by PatelNehal
no mail.php is not in the same directory, but i think its a part of pear and i haven't installed pear with PHP. I don't know about pear and its file structure.

Re: Need PHP Email Script and Configuration

Posted: Fri Mar 27, 2009 12:24 am
by sujithtomy
Hello,

your code
include("Mail.php");
So , please put Mail.php in the same folder as your script resides.
then have a try.
OR
specify full path to mail.php in include (include("PATH_TO/Mail.php");)

Re: Need PHP Email Script and Configuration

Posted: Sun Mar 29, 2009 6:39 am
by PatelNehal
i had search all the directory for Mail.php but i havent find it.

i had downloaded the script from somewhere and dont know why he had included the mail.php, i thought it is a built in file in php so is there any package i have to install with php for sending mail.

Re: Need PHP Email Script and Configuration

Posted: Sun Mar 29, 2009 8:50 am
by php_east
just delete include("Mail.php");