Page 1 of 1

Hotmail NOT accepting emails...

Posted: Fri Feb 09, 2007 9:15 pm
by Trenchant
Hotmail won't accept my emails. This is getting quite annoying. The script will send emails to my other private email address not hosted by hotmail. Anyone see anything wrong?

Code: Select all

<?php
session_start();

require('Swift/Swift.php');
require('Swift/Swift/Connection/SMTP.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Email</title>
</head>

<body>
<?php
if ($_POST['send_email']) {
	$to = $_POST['send_email'];
	
	$swift = new Swift(new Swift_Connection_SMTP('SMTP.accesscomm.ca', '587'));
	if ($swift->authenticate('lshaheen', '%%%%%')) {
		
		$email = 'This is my super special email.';
		
		$swift->setReplyTo('myotheremail@hotmail.com');
		$swift->addPart($email, 'text/html');
		$swift->send(
			$to,
			'proudly_canadian01@hotmail.com',
			'Here is the super important email!');
		var_dump($swift->transactions);
		$swift->close();
	} else {
		echo "Could not authenticate";
	}

} else {
	
	echo "<form action='?' method='post'><input type='text' name='send_email' value='@hotmail.com'><input type='submit' value='Send Email'></form>";
}
?>
</body>
</html>
This is the var dump

Code: Select all

array(8) 
	{
	[0]=>  array(3) 
	{
		["command"]=>  string(0) "" 
		["time"]=>  string(21) "0.89348300 1171077216" 
		["response"]=>  string(82) "220 mailout1.accesscomm.ca ESMTP Access Communications outbound mail server, eh! " 
	}
	[1]=>  array(3) 
	{
		["command"]=>  string(23) "EHLO www.webdummy.net " 
		["time"]=>  string(21) "0.91831300 1171077216" 
		["response"]=>  string(265) "250-mailout1.accesscomm.ca Hello static24-72-67-145.regina.accesscomm.ca [24.72.67.145], pleased to meet you 250-ENHANCEDSTATUSCODES 250-PIPELINING 250-8BITMIME 250-SIZE 31457280 250-DSN 250-AUTH DIGEST-MD5 CRAM-MD5 NTLM PLAIN LOGIN 250-DELIVERBY 250 HELP " 
	}
	[2]=>  array(3) 
	{
		["command"]=>  string(15) "AUTH CRAM-MD5 " 
		["time"]=>  string(21) "0.93029400 1171077216" 
		["response"]=>  string(66) "334 PDE2MDUyMTU1NDcuMTM0NDkyNTVAbWFpbG91dDEuYWNjZXNzY29tbS5jYT4= " 
	}
	[3]=>  array(3) 
	{
		["command"]=>  string(58) "bHNoYWhlZW4gYzdmNThhMGJlZWI3NTg2Y2RiMmZlMGZmZDFjYzY5Nzg= " 
		["time"]=>  string(21) "0.93989300 1171077216" 
		["response"]=>  string(28) "235 2.0.0 OK Authenticated " 
	}
	[4]=>  array(3) 
	{
		["command"]=>  string(45) "MAIL FROM: " 
		["time"]=>  string(21) "0.96461300 1171077216" 
		["response"]=>  string(57) "250 2.1.0 ... Sender ok " 
	}
	[5]=>  array(3) 
	{
		["command"]=>  string(43) "RCPT TO: " 
		["time"]=>  string(21) "0.99269500 1171077226" 
		["response"]=>  string(60) "250 2.1.5 ... Recipient ok " 
	}
	[6]=>  array(3) 
	{
		["command"]=>  string(6) "DATA " 
		["time"]=>  string(21) "0.00688800 1171077227" 
		["response"]=>  string(50) "354 Enter mail, end with "." on a line by itself " 
	}
	[7]=>  array(3) 
	{
		["command"]=>  string(907) "To: proudly_canadian01@hotmail.com
			From: proudly_canadian01@hotmail.com
			Reply-To:
			Subject: Here is the super important email!
			Date: Fri, 9 Feb 2007 21:13:40 -0600
			X-Mailer: Swift 2.1.6 by Chris Corbyn
			MIME-Version: 1.0
			Content-Type: multipart/mixed; boundary="_=_swift-1785645cd3860eb7158.52947666"
			Content-Transfer-Encoding: 8bit
			
			This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client. --_=_swift-1785645cd3860eb7158.52947666
			Content-Type: multipart/alternative; boundary="_=_swift-2533745cd3860eb7359.37314129"
			--_=_swift-2533745cd3860eb7359.37314129
			Content-Type: text/html; charset="ISO-8859-1"; format=flowed
			Content-Transfer-Encoding: 8bit
			This is my super special email.
			--_=_swift-2533745cd3860eb7359.37314129--
			--_=_swift-1785645cd3860eb7158.52947666--
			.
			" 
		["time"]=>  string(21) "0.01498300 1171077227" 
		["response"]=>  string(56) "250 2.0.0 l1A3BUrl015529 Message accepted for delivery "
	} 
}
feyd | Made sea of text more legible.

Posted: Sat Feb 10, 2007 9:03 am
by Chris Corbyn
They'll be getting blocked as spam by Hotmails strong junk filters.

If you have PHP5, try the new release candidate - mesages are a little more compliant, although it you're only sending ascii text it won't make a difference. Things that could be causing junk detection:

Short messages - as in, one sentence.
HTML-only messages -NEVER send a HTML message without sending the same content in plain-text. It gets points against it even in forgiving in spam checkers.
Untrusted hosts
Lack of SPF Record*** <---- Practically vital with hotmail
RBL listings - check all hosts the message goes through here

Posted: Sat Feb 10, 2007 11:33 am
by Trenchant
Hotmail shouldn't actually not accept the emails should it? I've checked junk mail folders and the emails don't even appear in there. I've added the sending email address to the safelist and that didn't help

Posted: Sat Feb 10, 2007 11:58 am
by Chris Corbyn
Hotmail only puts borderline stuff in Junk.

Did you check those links I posted? I'd almost bet that if you tried sending from PHPMailer or SquirellMail on the same server you'd not be able to send to Hotmail neither. The only way I've seen people fix this is to add a SPF record to their server because the first thing hotmail does is looks for a SPF record.

Code: Select all

; <<>> DiG 9.3.2 <<>> TXT w3style.co.uk
;; global options:  printcmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 60183
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;w3style.co.uk.                 IN      TXT

;; ANSWER SECTION:
w3style.co.uk.          3600    IN      TXT     "v=spf1 ip4:82.7.254.40/24 ip4:213.205.138.154 mx a -all"

;; Query time: 38 msec
;; SERVER: 194.168.4.100#53(194.168.4.100)
;; WHEN: Sat Feb 10 17:58:26 2007
;; MSG SIZE  rcvd: 99

Posted: Sat Feb 10, 2007 2:35 pm
by Trenchant
I don't think its that though because I have successfully sent several emails before using the above script. The only problem is I made some changes and I'm not sure what changes I made but it quit working.

Is there anything else it might be? If not I'll try to figure out this SPF thing. This isn't a large project so I don't want to go about changing a bunch of server settings.

Posted: Sat Feb 10, 2007 3:20 pm
by Chris Corbyn
Hmm, this is odd, I have to ask for my own sanity, but have you "tweaked" anything in the Swift code?

Code: Select all

From: proudly_canadian01@hotmail.com 
         Reply-To: 
         Subject: Here is the super important email! 
         Date: Fri, 9 Feb 2007 21:13:40 -0600 
         X-Mailer: Swift 2.1.6 by Chris Corbyn 
         MIME-Version: 1.0 
         Content-Type: multipart/mixed; boundary="_=_swift-1785645cd3860eb7158.52947666" 
         Content-Transfer-Encoding: 8bit 
          
         This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client. --_=_swift-1785645cd3860eb7158.52947666 
         Content-Type: multipart/alternative; boundary="_=_swift-2533745cd3860eb7359.37314129" 
         --_=_swift-2533745cd3860eb7359.37314129 
         Content-Type: text/html; charset="ISO-8859-1"; format=flowed 
         Content-Transfer-Encoding: 8bit 
         This is my super special email.
        --_=_swift-2533745cd3860eb7359.37314129-- 
         --_=_swift-1785645cd3860eb7158.52947666--
It's missing all the blank lines between the MIME parts

Code: Select all

From: proudly_canadian01@hotmail.com 
         Reply-To: 
         Subject: Here is the super important email! 
         Date: Fri, 9 Feb 2007 21:13:40 -0600 
         X-Mailer: Swift 2.1.6 by Chris Corbyn 
         MIME-Version: 1.0 
         Content-Type: multipart/mixed; boundary="_=_swift-1785645cd3860eb7158.52947666" 
         Content-Transfer-Encoding: 8bit 
          
         This part of the E-mail should never be seen. If you are reading this, consider upgrading your e-mail client to a MIME-compatible client.
         --_=_swift-1785645cd3860eb7158.52947666 
         Content-Type: multipart/alternative; boundary="_=_swift-2533745cd3860eb7359.37314129" 

         --_=_swift-2533745cd3860eb7359.37314129 
         Content-Type: text/html; charset="ISO-8859-1"; format=flowed 
         Content-Transfer-Encoding: 8bit

         This is my super special email.
        --_=_swift-2533745cd3860eb7359.37314129-- 
         --_=_swift-1785645cd3860eb7158.52947666--
There are consistently CRLF sequences missing from all the inner boundaries. I don't recall that ever being a bug in the library, however, I do notice you're on 2.1.6. Get 2.1.17, it's been out since October and is very stable. You can just overwrite your existing library with the updated one.

Posted: Sat Feb 10, 2007 5:14 pm
by Trenchant
That did the trick. I have been working at this for several weeks. I remember looking through the files at one point in time trying to find a way to simplify it all. I may have accidentally deleted too much at one point in time.

Its all working good now.

Posted: Sat Feb 10, 2007 5:45 pm
by Chris Corbyn
Excellente! :)

Posted: Sun Feb 11, 2007 12:07 am
by nickvd
Web Dummy wrote:That did the trick. I have been working at this for several weeks. I remember looking through the files at one point in time trying to find a way to simplify it all. I may have accidentally deleted too much at one point in time.

Its all working good now.
This would not only be prevented, but also the main point of unit testing, would it not?

(not an attack, but a legitimate question, as I try to wrap my head around the bloody thing)

Posted: Sun Feb 11, 2007 7:17 pm
by Trenchant
This is a little frustrating... It quite working again today after sending about 10 emails... It's still having now problem sending them to my local private email address though.

Posted: Mon Feb 12, 2007 4:20 am
by Chris Corbyn
Are you trying to send many emails (more than 10, say) through the SMTP server in one go? Many servers are configured to accept no more than 10 FROM envelopes in one session. Sending 10 emails with Swift (by default) is not the same as sending one email to ten recipients in thunderbird or other mail client since swift rewrites the email for each recipient so that only their address appears in the headers.

Could you send a copy of the email in question to chris@w3style.co.uk? What sort of content do the emails have? Are you sending plain AND html parts?

you have a HUGE security hole in your script

Posted: Sat Mar 03, 2007 3:17 pm
by audrey
$to = $_POST['send_email'];

If you're allowing users to specify any To: address, you essentially have an open relay for spammers to use. I hope you have some mechanism in place to keep the bots away.