Connecting Tech Pros Worldwide Help | Site Map

Problem occure in the mail() function

Banned
 
Join Date: Mar 2008
Posts: 10
#1: Mar 20 '08
Hi,

I run the following code error will occure. Plz tell that what mistake i have done
[php]<?php
// multiple recipients
$to = 'sravani_409@yahoo.com' . ', '; // note the comma
$to .= 'jyothsna11_123@yahoo.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</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: Mary <vani@eminosoft.com>, Kelly <sravanik@eminosoft.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <jyothsna11.123@gmail.com>' . "\r\n";
$headers .= 'Cc: soundarya_435@yahoo.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>[/php]
error :Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\mail1.php on line 43
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Mar 20 '08

re: Problem occure in the mail() function


This is the third and last warning.

Please enclose your posted code in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

Please use [code] tags in future.

MODERATOR
Newbie
 
Join Date: Mar 2008
Posts: 18
#3: Mar 20 '08

re: Problem occure in the mail() function


Quote:

Originally Posted by sravani1

Hi,

I run the following code error will occure. Plz tell that what mistake i have done
[php]<?php
// multiple recipients
$to = 'sravani_409@yahoo.com' . ', '; // note the comma
$to .= 'jyothsna11_123@yahoo.com';

// subject
$subject = 'Birthday Reminders for August';

// message
$message = '
<html>
<head>
<title>Birthday Reminders for August</title>
</head>
<body>
<p>Here are the birthdays upcoming in August!</p>
<table>
<tr>
<th>Person</th><th>Day</th><th>Month</th><th>Year</th>
</tr>
<tr>
<td>Joe</td><td>3rd</td><td>August</td><td>1970</td>
</tr>
<tr>
<td>Sally</td><td>17th</td><td>August</td><td>1973</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: Mary <vani@eminosoft.com>, Kelly <sravanik@eminosoft.com>' . "\r\n";
$headers .= 'From: Birthday Reminder <jyothsna11.123@gmail.com>' . "\r\n";
$headers .= 'Cc: soundarya_435@yahoo.com' . "\r\n";
$headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// Mail it
mail($to, $subject, $message, $headers);
?>[/php]
error :Warning: mail() [function.mail]: Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in D:\wamp\www\mail1.php on line 43

Hi Sravani,

Its an SMTP error. contact ur system administrator to set the settings of your server which u r using. SMTP u have to set an default emailid too. Default IP has to be changed.
All the Best,
Ramu
Hyderabad
ak1dnar's Avatar
Moderator
 
Join Date: Jan 2007
Location: Colombo
Posts: 1,439
#4: Mar 20 '08

re: Problem occure in the mail() function


Quote:

Originally Posted by Ramu528

Hi Sravani,

Its an SMTP error. contact ur system administrator to set the settings of your server which u r using. SMTP u have to set an default emailid too. Default IP has to be changed.
All the Best,
Ramu
Hyderabad

I think he is using his local windows machine, So System Administrator?

@Original Poster
Hi, just check your php.ini file for smtp settings. you have to use a real SMTP server IP/host and a port to send mails from your local machine. if you need more info on this please post back. thanks
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#5: Mar 20 '08

re: Problem occure in the mail() function


Quote:

Originally Posted by ak1dnar

I think he is using his local windows machine, So System Administrator?

@Original Poster
Hi, just check your php.ini file for smtp settings. you have to use a real SMTP server IP/host and a port to send mails from your local machine. if you need more info on this please post back. thanks

Probably quicker and easier to show (only) the mail and SMTP settings in your PHP.INI file here.

Ronald
Reply