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

  • Home
  • SEARCH
  • 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 1077411
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:34:18+00:00 2026-05-16T21:34:18+00:00

In one of my personal project I am developing a basic SMTP server in

  • 0

In one of my personal project I am developing a basic SMTP server in php. It’s ready and working when I launch it on its own from the command line; I access it correctly through telnet and it is responding correctly to SMTP commands and I access it correctly also from a php script sending an email using this server.

Now I have an issue when I launch the server from a php script and not from the command line (I do it using exec function). The server is responding correctly when I access it through telnet but not anymore from a php script sending an email.

Could anyone help me?

Note

To send emails from php scripts I use Mail PEAR extension. When I launch the server from within a script and try to send an email in the same process I get this error:

SMTP: Failed to connect socket: Connection refused (code: -1, response: )

Summary

My server implementation is in server.php and the script sending an email is in mail-test.php.

1) If I launch the server on the command line this way: php server.php and then launch php mail-test.php the script is processed normally and the email is sent. I can also access the server via telnet 127.0.0.1 3535 and communicating with the server normally.

2) Using an another script called test.php I wanted to wrap the server management, launching the server via exec("php server.php > /dev/null 2>&1 &"); and then doing the mail sending from that script in one shot. Doing that way, the server is correctly launched (I can access it via telnet) but emails sent from test.php thus after the server launch raise an error. If I send emails from an another script before killing the test.php process the email is correctly sent however…

I hope I am enough explicit.

  • 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-16T21:34:19+00:00Added an answer on May 16, 2026 at 9:34 pm

    Strangely, I resolved this issue by setting SO_RCVTIMEO this way:

    socket_set_option($sock, SOL_SOCKET, SO_RCVTIMEO, array('sec' => 0, 'usec' => 500))

    The error message I got was not really meaningful.

    I hope that it help others facing similar issue.

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

Sidebar

Related Questions

I am working on a personal project involving sending simple signals from my computer
I am currently designing a forum as a personal project. One of the recurring
I am working on a personal project as a way of learning more about
I'm working on a personal project (Search engine) and have a bit of a
I'm working on a personal project involving microphones in my apartment that I can
This is for a personal project of mine, and I have no idea from
I'm working on a personal project using WPF with Entity Framework and Self Tracking
I'm working on a personal project and I'd love to be able to say
I'm working on a personal project in Visual Studio 2010 Express edition, using ASP.NET
I have a personal project I'm working on that requires Microsoft SAPI5 -- text

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.