Featured post
sendmail - Send Mail using PHP failing -
i using same php code have used try , send form via email , getting message:
warning: mail() [function.mail]: failed connect mailserver @ "localhost" port 25, verify "smtp" , "smtp_port" setting in php.ini or use ini_set() in sendmailsuscribete.php on line 44
this lines 40 - 54:
$header .= "from: $email" . "\r\n"; $header .= "reply-to: $email" . "\r\n"; $header .= "return-path: $email" . "\r\n"; if(mail($to, $subject, $msg, $header)){ //message sent! redirect("http://www.domain.com/suscribete.html"); }else{ // display error message if message failed send echo " <div class=\"msgerror\"> <h1>error…</h1> <p>disculpa <b><?=$name;?></b>, tu mensaje falló en ser enviado. por favor vuelve intentar.</p> </div>"; }
i checked using phpinfo()
, know smtp set localhost , port uses 25 have no idea error may be.
update forgot running on windows server , php file 1 i've used unix servers, should contain different?
mail
cannot send e-mails directly (at least not on windows), needs smtp server. there no smtp server running on host on php-script being executed. solutions are:
- use library can send e-mails directly using smtp, phpmailer or swiftmailer (github repo).
- edit php.ini directives point smtp server accepts e-mails you. ask hosting provider if not know 1 use.
- set smtp server on localhost.
point 1. idea, because libraries provide abstractions make unnecessary deal low level stuff putting mime messages correctly. point 2. least trouble. advice against point 3. unless serious administering e-mail server yourself.
- Get link
- X
- Other Apps
Comments
Post a Comment