...

View Full Version : problem with mail function



swethak
07-21-2008, 04:35 PM
hi,

i run the below code i got the below error when i run in my local system.And i placed same program in website it works fine.plz tell that what's the mistake in that.


$to ="aa@gmail.com";
$subject = "Site Registration Confirmation";
$message = '<html>
<head>
<title>Site Registration Confirmation</title>
</head>
<body style=font-family:verdana, arial; font-size: .8em;>
You filled out a registration form
<br/><br/>
</body>
</html>';
//headers type to sent the mail
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
// from address is take what ever we want
$from = "me@example.com";
$headers .= "From: $from";
//mail function
mail($to,$subject,$message,$headers);



error :Warning: mail(): "sendmail_from" not set in php.ini or custom "From:" header missing in e:\project\DataMining\mailcheck.php on line 22

ramm19
07-21-2008, 07:27 PM
try adding this to the top of your php file..


ini_set ("sendmail_from","webmaster@yourdomain.com");

ramm19
07-21-2008, 07:35 PM
when i run in my local system

oops... just read that, you'll need to set a SMTP server (and port) in your php.ini file or like this:


ini_set ("SMTP","smtp.yourmailserver.com");
ini_set("SMTP_PORT","25");


BTW, your code should just work fine once you upload it to the server...

swethak
07-22-2008, 07:54 AM
hi,

i use the below code .but in that i got the error

And my php.ini contains

[mail function]
; For Win32 only.
SMTP = localhost ; for Win32 only
sendmail_from= me@localhost.com ; for Win32 only
SMTP_PORT=25;

; For Win32 only.
sendmail_from = me@example.com
SMTP_PORT=25


plz tell that whats the mistake.




<?php
ini_set ("SMTP","smtp.yourmailserver.com");
ini_set("SMTP_PORT","25");
$to ="sravanik@eminosoft.com";
$subject = "Site Registration Confirmation";
$message = '<html>
<head>
<title>Site Registration Confirmation</title>
</head>
<body style=font-family:verdana, arial; font-size: .8em;>
You filled out a registration form
<br/><br/>
</body>
</html>';
//headers type to sent the mail
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
// from address is take what ever we want
$from = "me@example.com";
$headers .= "From: $from";
//mail function
mail($to,$subject,$message,$headers);
?>



error :

Warning: mail(): Failed to connect to mailserver at "me@example.com " port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in F:\Facebook\mailcheck.php on line 24

ramm19
07-22-2008, 06:19 PM
swethak, you need an actual mail server ;)

if you are planning to have your own web server, you could ask your ISP for your SMTP server, and you have to put it where it says "smtp.yourmailserver.com", that was just an example.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum