Dear All,
I am running php4.4.2, Apache/2.2.0 and MySQL 4.
I have a php code which can send mail. but when I am trying to run the script with following command its fail.
# php testmail.php
If i try to run the script with following command then it will run successfully.
#php -n testmail.php
If any one know the solution please helm me.
Regards,
Jay Choksi
Problem in Mail Script
Moderator: General Moderators
Re: Problem in Mail Script
Code: Select all
-n No php.ini file will be usedPerhaps if you showed us your code and told us what "its fail" means then we could help you better...
-
jaychoksi2003
- Forum Newbie
- Posts: 2
- Joined: Mon Dec 15, 2008 11:53 pm
Re: Problem in Mail Script
Hi,
Below is my php code. Without -n option it will give me output as Mail Send.And I dont want to use -n option in php script. Because if I want to run script from web browser it will not run. I have to use command line with -n option I dont want that.
And another thing If I remove the php.ini file from /usr/local/lib/ then also it will run successfully but my others module(lib_pdf) will not load. So finally others modules and php.ini file is necessary for us.
#######################################################
<?php
// multiple recipients
$to = 'jomym@mail.abc.com' ; // note the comma
// subject
$subject = 'Test Mail';
// message
$message = '
<html>
<head>
<title>Test mail</title>
</head>
<body>
<p>Test mail</p>
<table>
<tr>
<td>Mail is working fine</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Jomy <jomym@mail.abc.com>' . "\r\n";
$headers .= 'From: Test Mail <no-reply@mail.abc.com>' . "\r\n";
//$headers .= 'Cc: jomym@mail.abc.com' . "\r\n";
$headers .= 'Bcc: jamesc@mail.abc.com' . "\r\n";
// Mail it
$k=mail($to, $subject, $message, $headers);
if ($k == 1)
echo "Mail successfully sent";
else
echo "Mail send failed";
?>
###############################################################
Below is my php code. Without -n option it will give me output as Mail Send.And I dont want to use -n option in php script. Because if I want to run script from web browser it will not run. I have to use command line with -n option I dont want that.
And another thing If I remove the php.ini file from /usr/local/lib/ then also it will run successfully but my others module(lib_pdf) will not load. So finally others modules and php.ini file is necessary for us.
#######################################################
<?php
// multiple recipients
$to = 'jomym@mail.abc.com' ; // note the comma
// subject
$subject = 'Test Mail';
// message
$message = '
<html>
<head>
<title>Test mail</title>
</head>
<body>
<p>Test mail</p>
<table>
<tr>
<td>Mail is working fine</td>
</tr>
</table>
</body>
</html>
';
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
// Additional headers
$headers .= 'To: Jomy <jomym@mail.abc.com>' . "\r\n";
$headers .= 'From: Test Mail <no-reply@mail.abc.com>' . "\r\n";
//$headers .= 'Cc: jomym@mail.abc.com' . "\r\n";
$headers .= 'Bcc: jamesc@mail.abc.com' . "\r\n";
// Mail it
$k=mail($to, $subject, $message, $headers);
if ($k == 1)
echo "Mail successfully sent";
else
echo "Mail send failed";
?>
###############################################################