Skip to content

Instantly share code, notes, and snippets.

@alexeyshockov
Created October 10, 2015 13:47
Show Gist options
  • Save alexeyshockov/d3f8b8ea0eb32bb32c10 to your computer and use it in GitHub Desktop.
Save alexeyshockov/d3f8b8ea0eb32bb32c10 to your computer and use it in GitHub Desktop.
Mailtrap.io PHP tests
$ php imap-test.php
int(1)
string(0) ""
<?php
print_first('mailtrap.io', 1100, '12920824f17df7168', '7803fea8172ffd');
function print_first($host, $port, $user, $password)
{
$mbox = imap_open('{'.$host.':'.$port.'/pop3}INBOX', $user, $password);
var_dump(imap_qprint(imap_body($mbox, 1)));
}
$ php zend-test.php
Fatal error: Uncaught exception 'Zend\Mail\Exception\RuntimeException' with message ' in /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Headers.php on line 109
Zend\Mail\Exception\RuntimeException: Line "From: Alexey Shockov <[email protected]>
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Subject: Test
Message-Id: <[email protected]>
Date: Sat, 10 Oct 2015 15:32:49 +0300
To: [email protected]
Mime-Version: 1.0 (Mac OS X Mail 8.2 \(2104\))
X-Mailer: Apple Mail (2.2104)
Test mail.
"does not match header format! in /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Headers.php on line 109
Call Stack:
0.0007 230592 1. {main}() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/zend_test.php:0
1.1241 1067992 2. Zend\Mail\Storage\AbstractStorage->current() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/zend_test.php:18
1.1241 1068064 3. Zend\Mail\Storage\Pop3->getMessage() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Storage/AbstractStorage.php:267
1.2670 1179288 4. Zend\Mail\Storage\Message->__construct() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Storage/Pop3.php:65
1.2670 1179592 5. Zend\Mail\Storage\Part->__construct() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Storage/Message.php:54
1.2679 1267184 6. Zend\Mail\Headers::fromString() /Users/alexeyshockov/Documents/Staffim/BehatMailExtension/vendor/zendframework/zend-mail/src/Storage/Part.php:108
<?php
require 'vendor/autoload.php';
use Zend\Mail\Storage\Pop3;
$mail = new Pop3([
'host' => 'mailtrap.io',
'port' => 1100,
'user' => '12920824f17df7168',
'password' => '7803fea8172ffd',
]);
foreach ($mail as $message) {
echo "Mail from '{$message->from}': {$message->subject}\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment