Jump to content

!! My Problem With Mail() Function !!


Sara_Sa

Recommended Posts

I've AppServ Open Project - 2.4.0 for Windows & PHP Version 4.3.6

 

But when I use mail() function  I see this error :

 

Warning: 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 c:\appserv\www\mail.php on line 33

 

How can I use ini_set() and send email messages from local server??

 

** note: I don't have enough information about mailserver **

 

 

Link to comment
https://forums.phpfreaks.com/topic/41627-my-problem-with-mail-function/
Share on other sites

To all you guys out there having problems with mail scripts throwing back this (and you know your scripts are right!!)...

 

Warning: mail() [function.mail]: "sendmail_from" not set in php.ini or custom "From:" header missing in:

 

I had started seeing this after moving some scripts from 4.3 servers to 5.

 

a dirty get around is using

 

ini_set ("sendmail_from","[email protected]");

 

to force the From header.

 

Not ideal but it works.

;)

just copy the code onto the forum, it makes it esier for everyone to help you.

 

This is the code:

 

<html>
<head><title>Send Email</title></head>
<body bgcolor="#EEEEEE">
<center>

<form action="mail.php" method="post">

<table cellpadding=2 cellspacing=0 border=0>
<tr><td><b>Sender</b></td><td><input type="text" name="you"></td></tr>
<tr><td><b>Recipient</b></td><td><input type="text" name="to"></td></tr>
<tr><td><b>Title</b></td><td><input type="text" name="tit"></td></tr>
<tr><td><b>Message</b></td><td><textarea rows=6 cols=16 name="msg" ></textarea></td></tr>
<tr><td> </td><td><input type="submit" value="Send Now"></td></tr>
</table>

</form>

<?php
if ($_SERVER["REQUEST_METHOD"]=="POST"){
mail("$to", "$tit", "$msg","From:$you");
}
?>

</center>
</body>
</html>

 

Thank You

 

 

Wow first of all it is a bad idea to not declare variable from a form, second of all it is a very bad idea.

 

Try this.

 

<?php
if ($_SERVER["REQUEST_METHOD"]=="POST"){
mail($_POST['to'], $_POST['tit'], $_POST['msg'],"From:" . $_POST['you']);
}
?>

</center>
</body>
</html>

 

Never refer to POST or GET variable just by their name, always define them or bad stuff can happen. That is why register_globals is turned off by default for security reasons.

 

--FrosT

frost110

 

My basic problem was in mail() function

 

I can't send email messages from local server

 

When I test that script I see the following error message:

 

Warning: mail(): Failed to connect to mailserver at "localhost" port 25 ..etc

 

???

 

But I learned important lesson today  :)

>> Never refer to POST or GET variable just by their name, always define them.. <<

 

Thank you so much frost110

 

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.