alkogolic Posted June 19, 2013 Share Posted June 19, 2013 How to send mail via command "HELO" "MAIL FROM"? Error "Warning: fsockopen() [function.fsockopen]: unable to connect to hotmail.com:25" Code: <? socketmail("hotmail.com", "asdasd22e@hotmail.com", "asd@yahoo.com", "sub", "mess"); function socketmail($server, $to, $from, $subject, $message) { $connect = fsockopen ($server, 25, $errno, $errstr, 30); fputs($connect, "HELO localhost\r\n"); fputs($connect, "MAIL FROM: $from\n"); fputs($connect, "RCPT TO: $to\n"); fputs($connect, "DATA\r\n"); fputs($connect, "Content-Type: text/plain; charset=iso-8859-1\n"); fputs($connect, "To: $to\n"); fputs($connect, "Subject: $subject\n"); fputs($connect, "\n\n"); fputs($connect, stripslashes($message)." \r\n"); fputs($connect, ".\r\n"); fputs($connect, "RSET\r\n"); } ?> Quote Link to comment Share on other sites More sharing options...
kicken Posted June 19, 2013 Share Posted June 19, 2013 Just download and use a library such as PHPMailer or SwiftMailer. Sending mail properly via SMTP is more complicated than just opening a socket and sending a bunch of commands. Quote Link to comment Share on other sites More sharing options...
alkogolic Posted June 19, 2013 Author Share Posted June 19, 2013 Thanks, but i want send email via command HELO. Why hotmail.com disconnect my? Quote Link to comment Share on other sites More sharing options...
gizmola Posted June 19, 2013 Share Posted June 19, 2013 Thanks, but i want send email via command HELO. Why hotmail.com disconnect my? First off... what you are saying you want to do is implement the SMTP protocol. That is non trivial, and the libraries suggested provide full implementations of those protocols. With that said, mail transfer agent (MTA) configuration and email verification in the age of spam is a fact of life. Email systems like hotmail do all sorts of things to verify where email is originating from, not limited to, checking for MX records, reverse dns verification, SPF verification and DKIM. In your example, trying to spoof a yahoo.com email sender is likely to just be rejected outright as spam because you will fail all sorts of spam checks on their server. They don't want people doing what you're trying to do, and you're wasting your time trying it. Of course there could also be a simpler explanation of your outright disconnection, in that hotmail.com is now defunct/deprecated and hotmail is now outlook.com. See: http://geeks.broadwayworld.com/article/Microsoft-Shutting-Down-Hotmail-After-16-Years-20130503 Even if it wasn't shutdown, there is really no reason to reinvent the wheel for smtp, with libraries that do it for you, not to mention, the mail() function. Quote Link to comment Share on other sites More sharing options...
alkogolic Posted June 20, 2013 Author Share Posted June 20, 2013 Yes, i want implement the SMTP protocol. <? $connect = fsockopen ("hotmail.com", 25, $errno, $errstr, 30); ?> Warning: fsockopen(): unable to connect to hotmail.com:25 in that hotmail.com is now defunct/deprecated and hotmail is now outlook.com <? $connect = fsockopen ("outlook.com", 25, $errno, $errstr, 30); ?> Warning: fsockopen(): unable to connect to outlook.com:25 Why? php script hosted in domain for example domain.com DNS records this is domain: Quote Link to comment Share on other sites More sharing options...
kicken Posted June 20, 2013 Share Posted June 20, 2013 neither hotmail.com nor outlook.com are the hosts you should be trying to connect to if you want to send mail to an @hotmail or @outlook address. Not going to say which are the proper addresses, if you want to be spamming people you can figure out how to do it yourself. Quote Link to comment Share on other sites More sharing options...
alkogolic Posted June 20, 2013 Author Share Posted June 20, 2013 I don't want to be spamming people. Quote Link to comment Share on other sites More sharing options...
gizmola Posted June 21, 2013 Share Posted June 21, 2013 In your example, you have an email where the sender is "someone@yahoo.com". Almost all systems do the following: - Check the sender domain (yahoo.com) - Get the mx records for that domain using DNS - Is this server who is connecting to me, an mx for yahoo.com? In your case, the answer is NO. The email will be either rejected, or accepted and immediately deleted from their queue. Obviously you are not even getting to that point, however, it is likely that you will end up there. Your immediate issue is this, the mx records for hotmail are: 5 mx2.hotmail.com 5 mx3.hotmail.com 5 mx1.hotmail.com 5 mx4.hotmail.com Again, if you don't understand SMTP and how email works, why are you trying to write your own SMTP stack? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.