php-imap icon indicating copy to clipboard operation
php-imap copied to clipboard

Add an ability to create/upload new messages

Open lwcorp opened this issue 4 years ago • 3 comments

Is your feature request related to a problem? Please describe. It's currently not possible to use this project to create new messages.

Describe the solution you'd like An ability to create new messages, which ideally means allowing to submit an external plaintext EML file, pull everything from there (message text, from, to, subject, date*, etc.) and upload it.

Alternatively, a more quick and dirty approach is to at least allow to submit a quick form with all relevant fields.

Additional context

  • I guess all this could be part of your Message.php.
  • Be sure to use the date just like in the native imap_append's $internal_date:

If this parameter is set, it will set the INTERNALDATE on the appended message. The parameter should be a date string that conforms to the rfc2060 specifications for a date_time value.

lwcorp avatar Apr 03 '21 11:04 lwcorp

Hi @lwcorp , I guess you are looking for this method: Folder::appendMessage()? :)

Best regards,

Webklex avatar Jun 17 '21 17:06 Webklex

Thanks, but if you refer to /blob/master/src/Folder.php then in appendMessage($message, ...) it states @param string $message, while I ask for $message to be an EML filename. BTW, why isn't any of this in php-imap.com's documentation?

lwcorp avatar Jun 17 '21 17:06 lwcorp

Hi @lwcorp , take a look at an .eml file in a text editor - it's a simple text file.

So in theory this could work:

$eml_template = file_get_contents("path/to/email.eml");
$folder->appendMessage($eml_template);

However I've never used this method - feel free to test or expand the functionality and push a pull request. Since I've never used this method, it is not documented. If you like to add it to the documentation, please head over to https://github.com/Webklex/php-imap-documentation/blob/master/05.api/03.folder/default.md

Best regards,

Webklex avatar Jun 18 '21 09:06 Webklex