Results 1 to 3 of 3

Thread: [RESOLVED] Connect to SMTP server?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    Resolved [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

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    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

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    190

    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
  •  



Click Here to Expand Forum to Full Width