|
-
Jun 30th, 2007, 02:00 AM
#1
Thread Starter
Addicted Member
[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
-
Jun 30th, 2007, 06:51 AM
#2
Re: Connect to SMTP server?
Exactly as it says.
As per the documentation for mail():
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
-
Jul 3rd, 2007, 10:27 AM
#3
Thread Starter
Addicted Member
Re: Connect to SMTP server?
Thanks
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|