[RESOLVED] Connect to SMTP server?
I've got an SMTP server on my computer and running a website on a host, I want my mailer to connect to my smtp server to send the mail, this is what I've done so far:-
PHP Code:
<?php
$server = "my ip";
$port = "25";
$to=$_POST['to'];
$subject=$_POST['subject'];
$from=$_POST['from'];
$body=$_POST['body'];
$headers = "From: $from";
$smtpconnect = fsockopen($server, $port);
if(mail($smtpconnect,$to,$subject,$body,$headers)) {
echo "Sent! <br><Br>Sent to: <br><Br><B>$to</B><br>Sent from: <B>$from</b><br>Message: <b>$body</b><br>";
} else {
echo "Failed! <br><br><B>$to</B><br>Sent from: <B>$from</b><br>Message: <b>$body</b><br>";
}
?>
I get the error:-
Warning: mail() expects parameter 1 to be string, resource given in mail.php on line 11
Re: Connect to SMTP server?
Exactly as it says.
As per the documentation for mail():
Quote:
bool mail ( string $to, string $subject, string $message [, string $additional_headers [, string $additional_parameters]] )
The SMTP server is specified using a configuration directive:
http://php.net/manual/en/ref.mail.php#ini.smtp
Re: Connect to SMTP server?