SMTP setup in php.ini with mail()function

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
fasp
Forum Newbie
Posts: 4
Joined: Wed Mar 31, 2004 10:32 am
Location: mexicali,mexico

SMTP setup in php.ini with mail()function

Post by fasp »

Hi, first of all thanks for your time.

I wanna send an email from my php page:
u should know that i got this laptop where is installled the apache server and php, im in windows XP, im not using IIS.

SO, i got this script

Code: Select all

<? 
if (!$HTTP_POST_VARS){ 
?> 
<form action="envia_form_php.php" method=post> 
Nombre: <input type=text name="nombre" size=16> 
<br> 
Email: <input type=text name=email size=16> 
<br> 
Comentarios: <textarea name=coment cols=32 rows=6></textarea> 
<br> 
<input type=submit value="Enviar"> 
</form> 
<? 
}else{ 
    //i got the form, building the form body
    $cuerpo = "Formulario enviado\n"; 
    $cuerpo .= "Nombre: " . $HTTP_POST_VARS["nombre"] . "\n"; 
    $cuerpo .= "Email: " . $HTTP_POST_VARS["email"] . "\n"; 
    $cuerpo .= "Comentarios: " . $HTTP_POST_VARS["coment"] . "\n"; 

    //sendin the email
    mail("sidiman2002@hotmail.com","Formulario recibido",$cuerpo); 

    //thanks for sendind the email
    echo "Gracias por rellenar el formulario. Se ha enviado correctamente."; 
} 
?>
of course there are alot of php email forms more easy and basic, but this one i found it from a friendly page. So anyway, if i use this script or another it show me this warning

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:\program files\apache group\apache\htdocs\envia_form_php.php on line 29

i look my php.ini and this is what i got on th MAIL FUNCTION LINES:

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

; For Win32 only.
;sendmail_from = me@localhost.com

; For Unix only. You may supply arguments as well (default: "sendmail -t -i").
;sendmail_path =




what's wrong???
User avatar
markl999
DevNet Resident
Posts: 1972
Joined: Thu Oct 16, 2003 5:49 pm
Location: Manchester (UK)

Post by markl999 »

In your php.ini try replacing:
SMTP = localhost ;
with
SMTP = yourisp.smtp.com

Where 'yourisp.smtp.com' is your ISP's smtp server, the same server you use to send email via outlook/outlook express for example (your ISP's homepage should provide details). Once you've changed php.ini be sure to restart apache.
Post Reply