i've got a php function which sends emails fine but I want it to use the smtp server i have specified in the ini.set function.
if i delete these 3 lines of code the email still sends fine.
the reason i want to use the smtp server is because sometimes this does not work to certain mail hosts.
connect();
$username = mysql_real_escape_string($_POST['username']);
$result = mysql_query("SELECT email FROM members WHERE username = '$_POST[username]'")
or die ("Error - Something went wrong.");
$row = mysql_fetch_array($result);
$useremail = $row['email'];
$name = "name";
$mail_from = "noreply@name.com";
$mail_to = "$useremail";
$mail_body = "Hello. Thank you for registering. Please click the link below to confirm your email address. ";
$mail_subject = "Confirm you registration".$name;
$mail_header = "From: ".$name." <".$mail_from.">\r\n";
ini_set ("SMTP", "ssl://serveraddress");
ini_set("smtp_port","465");
ini_set("sendmail_from","noreply@name.com");
$sendmail = mail($mail_to, $mail_subject, $mail_body, $mail_header);
if($sendmail == true) { mail("john@name.com", "email sent ok", "email sent to '$_POST[email]'", "yea sent ok");}
Else { mail("john@name.com", "email ERROR", "email not sent to '$_POST[email]'", "yea we got a problem");}
}