Need PHP Email Script and Configuration

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
PatelNehal
Forum Newbie
Posts: 21
Joined: Mon Mar 23, 2009 7:27 am
Location: Gujarat, India

Need PHP Email Script and Configuration

Post 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?
sujithtomy
Forum Commoner
Posts: 46
Joined: Tue Mar 24, 2009 4:43 am

Re: Need PHP Email Script and Configuration

Post by sujithtomy »

Hello,

is Mail.php is the same directory ??
User avatar
PatelNehal
Forum Newbie
Posts: 21
Joined: Mon Mar 23, 2009 7:27 am
Location: Gujarat, India

Re: Need PHP Email Script and Configuration

Post 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.
sujithtomy
Forum Commoner
Posts: 46
Joined: Tue Mar 24, 2009 4:43 am

Re: Need PHP Email Script and Configuration

Post 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");)
User avatar
PatelNehal
Forum Newbie
Posts: 21
Joined: Mon Mar 23, 2009 7:27 am
Location: Gujarat, India

Re: Need PHP Email Script and Configuration

Post 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.
User avatar
php_east
Forum Contributor
Posts: 453
Joined: Sun Feb 22, 2009 1:31 pm
Location: Far Far East.

Re: Need PHP Email Script and Configuration

Post by php_east »

just delete include("Mail.php");
Post Reply