eden-php / mail Goto Github PK
View Code? Open in Web Editor NEWEden POP3, IMAP and SMTP component
License: MIT License
Eden POP3, IMAP and SMTP component
License: MIT License
Is it possible to mark message as SEEN via IMAP?
FatalThrowableError in Pop3.php line 452:
For some reason, Pop3 class needs a imap function, this function is declared on Imap class.
I tried simple commands, none of them did not work.
For example I requested for emailBoxes.
the reponse from yandex was :
array(10) { [0]=> string(80) "* LIST (\Unmarked \HasNoChildren \Sent) "|" "&BB4EQgQ,BEAEMAQyBDsENQQ9BD0ESwQ1-"" [1]=> string(66) "* LIST (\Unmarked \HasNoChildren) "|" "&BBgEQQRFBD4ENARPBEkEOAQ1-"" [2]=> string(59) "* LIST (\Unmarked \HasNoChildren \Junk) "|" "&BCEEPwQwBDw-"" [3]=> string(71) "* LIST (\Marked \HasNoChildren \Trash) "|" "&BCMENAQwBDsENQQ9BD0ESwQ1-"" [4]=> string(74) "* LIST (\Unmarked \HasNoChildren \Drafts) "|" "&BCcENQRABD0EPgQyBDgEOgQ4-"" [5]=> string(44) "* LIST (\Unmarked \HasChildren) "|" Archives" [6]=> string(53) "* LIST (\Unmarked \HasNoChildren) "|" "Archives|2017"" [7]=> string(39) "* LIST (\Marked \NoInferiors) "|" INBOX" [8]=> string(47) "* LIST (\Unmarked \HasNoChildren) "|" Templates" [9]=> string(23) "TAG2 OK LIST Completed." }
but the result of $imap->getEmailTotal() was:
Array ( [0] => ???????????? [1] => ????????? [2] => ???? [3] => ????????? [4] => ????????? [5] => | [6] => Archives|2017 [7] => | [8] => | )
When getEmails()
is called, it will set seen
flag on every message that is fetched. This makes it difficult to mark messages as "unread" in the fetched list. Ideally, when messages(list, not full message body) are fetched, this behavior should be avoided. To fix this, I replaced code in line 313 of Imap.php
(I haven't used POP3 yet, you can imitate this behavior there, if needed):
Replace:
$items = array('UID', 'FLAGS', 'BODY[HEADER]'); // Line 313
with
$items = array('UID', 'FLAGS', 'BODY.PEEK[HEADER]');
and the problem will be fixed. Cheers!
Is there an way to set the name of the sender & receiver?
If i try to remove a message, what number (uid) i have to provide?
If i do getEmails( 1, 1 )
it should return $Message #1 right?
remove( 1 )
has to (at least) mark it as deleted= won't work
$Message['Id']
: remove( '<some strange id here>' )
= won't work
Am I doing it wrong, or is something broken?
PS: There is no field $Message['Uid']
as in imap message
When a character is sent (á, é, í, ú, ó, ñ...), the function returns false and messes up on some email clients (sets the charset to US-ASCII). Maybe switch the returns will fix this?
Hi,
I have a problem when I try to send an attachment..
My code :
$nameImage = "file.jpg";
$pathToFile = "../../Data/Image/file.jpg";
$typeMime = mime_content_type($pathToFile);
$smtp = eden('mail')->smtp(_SMTP,_USER_EMAIL,_USER_PASSWORD,465,true);
$smtp->setSubject("Subject")
->setBody($MessageDecode,true)
->addTo($Email)
->addAttachment($nameImage , $pathToFile, $typeMime)
->send(array("From"=>"Me"));
$smtp->disconnect();
When I receive the e-mail, the attachment is invalid :/
An idea ? A solution ?
Thx :)
Hello,
After I installed the latest version via composer and run
$database = eden('mysql', '[HOST]' ,'[DBNAME]', '[USER]', '[PASS]'); //instantiate
I get a msg:
Fatal error: Call to undefined function eden() in /index.php on line
I search this error on google and see this issues Eden-PHP/Mysql#1
I add Eden::DECORATOR; after require autoload
require_once __DIR__.'/vendor/autoload.php'; Eden::DECORATOR;
And I get a new php error:
Notice: Undefined variable: message in D:\HomeServer\htdocs\phpdemo\mail\vendor\eden\core\src\Argument.php on line 54
Notice: Undefined variable: code in D:\HomeServer\htdocs\phpdemo\mail\vendor\eden\core\src\Argument.php on line 54
Please help me, thanks!
Warning: mb_strpos() expects parameter 1 to be string, array given in vendor/eden/mail/src/Imap.php on line 988
$attachment = isset($headers2['content-type'])
&& strpos($headers2['content-type'], 'multipart/mixed') === 0;
A vendedora não recebeu pelo produto: R517566747, o pedido finalizou no dia 14/11/2018.
How to extract attachment, saving, or download ?
result is just strings:
$email = $imap->getUniqueEmails(299, true);
echo $email['attachment']['presentasi hasil.pptx'];
do I have to create my own header attachment to be able to download it directly?
I get an "undefined offset" notice when the if statement within foreach is true, when nothing has yet been assigned to $head.
Undefined offset: -1
file: /Users/admin/Coding/pgm-impexp/vendor/eden/mail/src/Imap.php
line: 898
$lines = explode("\n", $head);
$head = array();
foreach ($lines as $line) {
if (trim($line) && preg_match("/^\s+/", $line)) {
$head[count($head)-1] .= ' '.trim($line);
continue;
}
$head[] = trim($line);
}
Perhaps the if condition can be updated like this:
if (count($head) > 0 && trim($line) && preg_match("/^\s+/", $line)) {
Thank you for your contribution! I want to use Proxy, but I'm not found any method! Thank You
I am using in Laravel 5.4 and I am getting the following error:
Undefined variable: message
in Argument.php (line 55).
One of the solution I found it to remove arguments from function i():
like
return new $class($message, $code); -> return new $class();
But then it is giving me error:
Call to undefined method Illuminate\Support\Facades\Mail::imap() ...
will someone kindly help me
Hello,
Using Eden like this:
Eden::DECORATOR;
$imap = eden('mail')->imap(
'imap.gmail.com',
'[email protected]',
'xxxx',
993,
true);
$mailboxes = $imap->getMailboxes();
$imap->setMailboxes('INBOX')->getActiveInbox();
$emails = $imap->getEmails(0, 3);
$count = $imap->getEmailTotal();
echo '<pre>';
print_r($emails);
echo '</pre>';
$imap->disconnect();
And getting error:
Fatal error: Uncaught Eden\Core\Exception: Both Physical and Virtual method Eden\Mail\Imap->setMailboxes() does not exist.
Notice: Undefined variable: message in ../vendor/eden/core/src/Argument.php on line 54
PHP Notice: Undefined variable: code in ../vendor/eden/core/src/Argument.php on line 54
The function getParts() of src/Pop3.php fails when some header information is not written in lowercase, like Boundary=... instead of boundary=....
Solution is to replace
$extra[$key] = $value;
with
$extra[strtolower($key)] = $value;
//foreach extra
foreach ($extra as $i => $attr) {
//transform the extra array to a key value pair
$attr = explode('=', $attr, 2);
if (count($attr) > 1) {
list($key, $value) = $attr;
$extra[strtolower($key)] = $value;
}
unset($extra[$i]);
}
When setting up a new Imap class like so:
$imap = new Eden('imap.gmail.com', '[email protected]', 'x-my-very-secret-password', '993', true);
and trying to fetch the mailboxes like so $imap->getMailboxes()
I get the following error message:
PHP error: Undefined variable: message in (..laravel..)/vendor/eden/core/src/Argument.php on line 54
It seems to involve the following snippet
/**
* One of the hard thing about instantiating classes is
* that design patterns can impose different ways of
* instantiating a class. The word "new" is not flexible.
* Authors of classes should be able to control how a class
* is instantiated, while leaving others using the class
* oblivious to it. All in all its one less thing to remember
* for each class call. By default we instantiate classes with
* this method.
*
* @param mixed[,mixed..] $args Arguments to pass to the constructor
*
* @return Eden\Core\Argument
*/
public static function i()
{
$class = __CLASS__;
return new $class($message, $code); // <-- this line
}
I haven't found the solution yet, but it seems that $message
is never set.
And how to set as read only if we want to set?
@cblanquera @aprilsacil @clark21
Please help
I have installed but still cannot figure it out, how to use this, this issue linked to https://github.com/Eden-PHP/Mail/issues/11
"/^=?[a-zA-Z]+-[0-9]+.*?/ is not fully correct.
For example KOI8-R encoding did not pass this regular.
In method:
public function remove($uid)
the parameter expected must be an integer or string. However, when a move procedure is called in
public function move($uid, $mailbox)
the $uid is an integer or string as well, but the line 374 to 376
if (!is_array($uid)) {
$uid = array($uid);
}
forces an array type in it to be used in implode(). And in line 380 it calls the remove($uid) without transforming it back to integer or string, causing an exception:
PHP Fatal error: Uncaught exception 'Eden\Core\Exception' with message 'Argument 1 in Eden\Mail\Imap->remove() was expecting int or string, however Array was given.' in /var/www/Apps/Integrata/Sync/vendor/eden/core/Eden/Core/Exception.php:61
It's setActiveMailbox
on imap. Had to look into the files for that.
And maybe also quite interesting. If you search for mails and you would like to get the body, too, set body true.
Anyway, very nice lib, but doc needs more work :D
In some circumstances attachments are not recognized in getParts() of src/Pop3.php.
Look at this header part for example:
Content-Type: application/pdf
Content-Length: 71203
Content-Disposition: attachment; filename="RG150289993335.pdf"
Content-Transfer-Encoding: base64
Normally Eden would expect the filename to be part of the the Content-Type line:
Content-Type: application/pdf; name="RG150289993335.pdf"
If not, Eden fails to recognize it as an attachment.
My (possibly dirty) fix is to add after
$extra = array();
if (count($type) == 2) {
$extra = explode('; ', str_replace(array('"', "'"), '', trim($type[1])));
}
the following line:
if (isset($head['content-disposition'])) {
$extra = array_merge($extra, explode('; ', str_replace(array('"', "'"), '', $head['content-disposition'])));
}
And then after
foreach ($extra as $i => $attr) {
//transform the extra array to a key value pair
$attr = explode('=', $attr, 2);
if (count($attr) > 1) {
list($key, $value) = $attr;
$extra[strtolower($key)] = $value;
}
unset($extra[$i]);
}
this line:
if (isset($extra['filename'])) {
if (!isset($extra['name'])) {
$extra['name'] = $extra['filename'];
}
unset($extra['filename']);
}
Is there an way to set the name of the sender & receiver?
Base64 line length should be only 76 characters, otherwise SpamAssassin gives negative score.
https://wiki.apache.org/spamassassin/Rules/BASE64_LENGTH_78_79
How to resolve? Just replace 998 by 76 in this two lines:
line 612: $count = ceil(strlen($data) / 998);
line 621: $body[] = substr($data, ($i * 998), 998);
For me, whenever I try to connect or run the eden function. PHP says that eden is not defined or is not a function. Why is this happening, I followed the instructions. I included the autoload.php file from vendor.
Hi, getting the following error with trace:
Undefined variable $message
... vendor/eden/core/src/Argument.php:54
vendor/eden/core/src/Route.php:119
vendor/eden/core/src/Base.php:598
vendor/eden/core/src/Base.php:72
vendor/eden/core/src/Control.php:20
Using code
$this->pop = eden('mail')->pop3(MAIL_SERVER,
USERNAME,
PASSWORD);
When downloading certain emails "in vendor/eden/mail/src/Imap.php at line 1371".
Here's what imap pushes to Eden
array('header' => '', 'headers' => object(stdClass), 'tos' => array(), 'ccs' => array(), 'bccs' => array(), 'ID' => array())
Annoying since i cannot download whole mailbox that contains less than 90 mails.
I configured with office 365 POP3 settings. Connection is successful but when try to use getEmailTotal, it's always returning 0 and getEmails response is also empty. checked with some others like ionos etc, working fine for them
$ composer install eden/mail
Invalid argument eden/mail. Use "composer require eden/mail" instead to add packages to your composer.json.
$imap = eden('mail')->imap(
'imap.gmail.com',
'[email protected]',
'[YOUR PASSWORD]',
993,
true);
eden is function? I can't find eden source.
And which file should I include?
When I tried to get maillist from gmail it returns followings. Where Can I get Mail Class?
Fatal error: Uncaught exception 'Eden\Core\Exception' with message 'Class Mail does not exist' in /home/user/www/vendor/eden/core/src/Control.php:26
Stack trace:
#0 /home/user/www/vendor/eden/core/src/Base.php(246): Eden\Core\Exception::i('Class Mail does...')
#1 /home/user/www/vendor/eden/core/src/Control.php(26): Eden\Core\Base->__invoke(Array)
#2 /home/user/www/classes/MailReader.php(65): eden('mail')
#3 /home/user/www/classes/MailReader.php(112): MailReader->read_email()
#4 /home/user/www/scripts/mail-parser.php(24): MailReader->process()
#5 {main}
thrown in /home/user/www/vendor/eden/core/src/Control.php on line 26
i cant delete messages. i have to switch off this library -
it's too bad because i prefer this over the alternatives.
In getParts() of src/Pop3.php there is a case missing for 8 bit content transfer encoding:
8bit is already UTF-8 (as I know, but I am not 100 % sure), so not more than extending the switch is necessary:
switch (strtolower($head['content-transfer-encoding'])) {
case 'binary':
$body = imap_binary($body);
break;
case 'base64':
$body = base64_decode($body);
break;
case 'quoted-printable':
$body = quoted_printable_decode($body);
break;
case '7bit':
$body = mb_convert_encoding($body, 'UTF-8', 'ISO-2022-JP');
break;
case '8bit':
break;
default:
$body = str_replace(array("\n", ' '), '', $body);
break;
}
How to resolve this?
$imap = eden('mail')->imap(
'imap.mail.ru',
"[email protected]",
"_*",
993,
true);
$imap->setActiveMailbox('INBOX');
$emails = $imap->search(['FROM "[email protected]"'],0,10);
var_dump( $emails );//
array (size=0)
empty
a letter from the sender is present [email protected]
Content-Type can contains field "charset". I think that it would be logical way to convert it to utf8, because returned message from function does not contains information about extra fields.
$parts[$type] = isset($extra['charset']) ? mb_convert_encoding($body, 'UTF-8', $extra['charset']) : $body;
composer install
should be composer require
in your readme.md.
Please help!
bug work in imap.mastermail.ru
I modifed this method:
/**
* Returns a list of mailboxes
*
* @return array
*/
public function getMailboxes()
{
if (!$this->socket) {
$this->connect();
}
$response = $this->call('LIST', $this->escape('', '*'));
$mailboxes = array();
foreach ($response as $line) {
if (strpos($line, 'Noselect') !== false || strpos($line, 'LIST') == false) {
continue;
}
//* LIST (\HasNoChildren) "/" &BBQEPQQ1BDIEPQQ4BDo-
if(!preg_match("~(\*\sLIST\s\(.*?\))\s\"(.)\"\s(.*)~is", $line, $match)){
continue;
}
$name = trim($match[3],'"');
$m2 = explode("{$match[2]}", $name );
$mailboxes[$name] = [
'name' => $m2[count($m2)-1],
"parent" => $m2[count($m2)-2]
];
}
return $mailboxes;
}
require 'vendor/autoload.php';
$imap = eden('mail')->imap(
'server179.web-hosting.com',
'[email protected]',
'lawyer12345?',
993,
true);
$mailboxes = $imap->getMailboxes();
print_r( $mailboxes );
When e-mail part is encoded as binary, the function imap_binary() is called. But imap_binary() is part of PHP IMAP extension and thus should be required in composer neon. If the extension is not loaded, then Fatal Error Call to undefined funcion Eden\Mail\imap_binary() is thrown.
public function getMailboxes()
{
if (!$this->socket) {
$this->connect();
}
$response = $this->call('LIST', $this->escape('', '*'));
$mailboxes = array();
foreach ($response as $line) {
if (strpos($line, 'Noselect') !== false || strpos($line, 'LIST') == false) {
continue;
}
$line = explode('"."', $line);
if (strpos(trim($line[0]), '*') !== 0) {
continue;
}
$mailboxes[] = $line[1];
}
return $mailboxes;
}
The above code resolves the issue with the getMailboxes returning only '.' as the list of mailboxes.
Undefined offset: 1 in eden/mail/src/Imap.php 1394.
This happens when the email doesn't have subject.
Is there a way for imap / pop, to disable the SSL certificate check for like self-signed certificates etc.?
Hello
how can i use eden without using composer !?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.