Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7042739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:12:17+00:00 2026-05-28T02:12:17+00:00

I am using phpmailer to send e-mails and had some problems with sending on

  • 0

I am using phpmailer to send e-mails and had some problems with sending on my hosting when I need to connect to remote mail server.
I got info from tech support that I need to bind my server ip with remote server.
It’s the first time I am messing with sockets ever.

Unfortunately phpmailer uses fsocketopen, so this is how I changed it:

//my replacement code
$socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
$conn = socket_connect($socket, $host, $port);
if($conn) {
    $this->smtp_conn = $socket;
} else {
    throw new Exception("Failed to connect to server: ".socket_last_error($socket));
}

//original phpmailer code
/**
$this->smtp_conn = @fsockopen($host,    // the host of the server
                             $port,    // the port to use
                             $errno,   // error number if any
                             $errstr,  // error message if any
                             $tval);   // give up after ? secs
 */

But after that change I receive warnings:

  • Warning: fputs(): supplied resource is not a valid stream resource

  • Warning: socket_get_status(): supplied resource is not a valid stream
    resource

How can I create resource that would be compatible with resource returned from fsockopen?
Using var_dump it says those two vars are both sockets. But I still get warnings for resource created usign socket_create.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T02:12:18+00:00Added an answer on May 28, 2026 at 2:12 am

    You need a stream resource returned, not a socket resource. Trying using the function stream_socket_client().

    $this->smtp_conn = stream_socket_client("tcp://".$host.":".$port,
    $errno,
    $errstr,
    $tval);
    

    Also, are you sure your hosting provider allows you to send email outbound directly from your server? Sometimes they will provide a relay mail server for you to use for outbound email.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im using PHP's mail() function to send some emails. But all my mails land
Hay I'm using PHPMailer to send some simple emails, however the function SetFrom() doesn't
I am using phps mail() function to send confirmation e-mails. The e-mails get received
I am using PHP mailer to send mails to my clients. I need to
I'm trying to send out mail using Google's SMTP in combination with PHPMailer, but
I'm using PHPMailer for a while now and never really had any problems, but
I'm trying to send SMTP e-mails using PHPMailer, but I keep getting this error
I'm using the PHPMailer-Lite class to build an email sending script and I'm not
I'm using PHPMailer to send out site contacts. In development, the script works perfectly
I'm using PHPMailer and it uses fsockopen to access the SMTP server. But the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.