Php contact form with smtp host relay

hi to all !

i’m using a php contact form with image verification than works very well.
so the issue is than a few days ago i was installed my own smtp MTA relay for outgoing mails, so i wish to modify my contact form for send the emails by the specifi smtp host AND PORT.

so here is the code than i’m using…


<?php

if(!$_POST) exit;

$email = $_POST['email'];
$verif_box = $_POST["verif_box"];

if(md5($verif_box).'a4xn' != $_COOKIE['tntcon']){
$error.='Numero antibot erroneo, vuelva a actualizar la pagina'; 
$errors=1; 
}
if(!eregi("^[a-z0-9]+([_\\\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\\.-][a-z0-9]+)*)+"."\\\\.[a-z]{2,}"."$",$email )){
$error.="Email invalido";
$errors=1;
}
if($errors==1) echo $error;
else{

$values = array ('name','email','phone','concerning','message');
$required = array('name','email','message');
 
$your_email = "theemail@xample.com";
$email_subject = "Formulario example.com";
$email_content = "Nuevo mensaje por formulario :\
 \
";
 
foreach($values as $value){
  if(in_array($value,$required)){
    if( empty($_POST[$value]) ) { echo 'fill all the fields'; exit; }
    $email_content .= $value.': '.$_POST[$value]."\
";
  }
}
 
if(mail($your_email,$email_subject,$email_content)) { setcookie('tntcon',''); echo 'information was sent !';} else { echo 'ERROR!';}

}

?>

i was searched in google for how to specify the host and port for send the email, but i was unable to put in the script for work :S

so any suggestion ?

thanks a lot!
clonick

Sure, check out SwiftMailer, you can just download the library and you’re good to go.

Whilst you’re there, check out the docs on SMTP authentication.

hi,

anyone have a suggestion or solution for this ?

thanks

i think i need to have PEAR installed, but i have a linux hosting in godaddy and i believe than i’m have pear.

exist some other solution ? thanks

ok i know than i need to put this…

$host = “outgoingrelay.smtp.com”;
$port = “25”; //will be other port, for it reason i need to customize it!

$smtp = Mail::factory(‘smtp’,
array (‘host’ => $host,
‘port’ => $port,
‘auth’ => false));
// ‘username’ => $username,
// ‘password’ => $password));

i’m not will use a SASL auth because i can’t set success :S lol but i was able to put another type of security, ok ? in this case the AUTH will not use…

and i think the problem is in the last line… maybe will be moreless like:


if($smtp->send(mail($your_email,$email_subject,$email_content))) { setcookie(‘tntcon’,‘’); echo ‘information was sent’;} else { echo ‘ERROR!’;}


so any suggestion ? :S