SMTP server responses

  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 328
  • Loc: Canada

Post 3+ Months Ago

Hi All

I have the following PHP script:

Code: [ Select ]
$sock = fsockopen($host, 25, $errno, $errstr, $timeout);
if(!sock)
{
echo "Connection To Mail Server Failed";
exit;
}
else
{
echo "You connected to server";
echo"<br />";
fputs($sock, "HELO ".$host."\r\n");
$reply = fgets($sock, 1024);


fclose($sock);
}
  1. $sock = fsockopen($host, 25, $errno, $errstr, $timeout);
  2. if(!sock)
  3. {
  4. echo "Connection To Mail Server Failed";
  5. exit;
  6. }
  7. else
  8. {
  9. echo "You connected to server";
  10. echo"<br />";
  11. fputs($sock, "HELO ".$host."\r\n");
  12. $reply = fgets($sock, 1024);
  13. fclose($sock);
  14. }


When I connect to server I get the message:
"You connected to server" but do not see any reply from the server.

I know I must be connected or else I would have got the Failed message.

Can someone help me here so that I can also see the server messages.

Thanks
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

i was looking at this tutorial about sending emails manually through telnet and then converting that into a php script. it could be some idea's on how to go about this.

Full code
Code: [ Select ]
<?php
$smtp_server = fsockopen("smtp.mydomain.com", 25, $errno, $errstr, 30);
if(!$server_smtp)
{
    // We have an error, do something
    exit;
}
fwrite($smtp_server, "HELO its_me\r\n");
fwrite($smtp_server, "MAIL FROM:<me@mydomain.com>\r\n");
fwrite($smtp_server, "RCPT TO:<myfreind@hisdomain.com>\r\n");
fwrite($smtp_server, "DATA\r\n");
fwrite($smtp_server, "Received: from mydomain.com by hisdomain.com ; Thu, 03 Jan 2006 12:33:29 -0700\r\n");
fwrite($smtp_server, "Date: Thu, 03 Jan 2006 12:33:22 -0700\r\n");
fwrite($smtp_server, "From: Me <me@mydomain.com>\r\n");
fwrite($smtp_server, "Subject: The Next Meeting of the Board\r\n");
fwrite($smtp_server, "To: myfreind@hisdomain.com\r\n");
fwrite($smtp_server, "\r\nMyFreind:\r\nHow are you ?\r\n\r\n       Me.\r\n");
fwrite($smtp_server, ".\r\nQUIT\r\n");
?>
  1. <?php
  2. $smtp_server = fsockopen("smtp.mydomain.com", 25, $errno, $errstr, 30);
  3. if(!$server_smtp)
  4. {
  5.     // We have an error, do something
  6.     exit;
  7. }
  8. fwrite($smtp_server, "HELO its_me\r\n");
  9. fwrite($smtp_server, "MAIL FROM:<me@mydomain.com>\r\n");
  10. fwrite($smtp_server, "RCPT TO:<myfreind@hisdomain.com>\r\n");
  11. fwrite($smtp_server, "DATA\r\n");
  12. fwrite($smtp_server, "Received: from mydomain.com by hisdomain.com ; Thu, 03 Jan 2006 12:33:29 -0700\r\n");
  13. fwrite($smtp_server, "Date: Thu, 03 Jan 2006 12:33:22 -0700\r\n");
  14. fwrite($smtp_server, "From: Me <me@mydomain.com>\r\n");
  15. fwrite($smtp_server, "Subject: The Next Meeting of the Board\r\n");
  16. fwrite($smtp_server, "To: myfreind@hisdomain.com\r\n");
  17. fwrite($smtp_server, "\r\nMyFreind:\r\nHow are you ?\r\n\r\n       Me.\r\n");
  18. fwrite($smtp_server, ".\r\nQUIT\r\n");
  19. ?>


http://www.mustap.com/phpzone_post_95_sending-email-in-php-the-hac
  • wpas
  • Proficient
  • Proficient
  • User avatar
  • Posts: 328
  • Loc: Canada

Post 3+ Months Ago

Hi Zealous

I saw that web page.
Tried fwrite() but still got nothing.

is there any way to put a debug in my script so that it prints out anything it gets
  • Zealous
  • Guru
  • Guru
  • User avatar
  • Posts: 1244
  • Loc: Sydney

Post 3+ Months Ago

what about the developer console in Firefox, there would have to be a plugin that would monitor the page echo.

just thinking did u check the apache error log and the main apache log, could be a start?
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8417
  • Loc: USA

Post 3+ Months Ago

I don't know if you got it resolved or not, and I realize that this topic is a little bit old, but its in an unresolved status, so I thought I'll put in my post in here so it may come in handy for someone else.

Did you try reading through the class provided here? That class has something like what I think you we're asking for... Maybe you'll be able to get some help from that class.

Post Information

  • Total Posts in this topic: 5 posts
  • Users browsing this forum: No registered users and 34 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.