Hier werden die Unterschiede zwischen zwei Versionen gezeigt.
Both sides previous revision Vorhergehende Überarbeitung Nächste Überarbeitung | Vorhergehende Überarbeitung | ||
php:imap [2021/03/31 12:46] webproducer PHP-Klasse "imap" ergänzt |
php:imap [2022/08/17 10:49] (aktuell) webproducer SSL ergänzt |
||
---|---|---|---|
Zeile 15: | Zeile 15: | ||
private $username = ''; | private $username = ''; | ||
private $password = ''; | private $password = ''; | ||
+ | private $port = 143; | ||
+ | private $type = 'IMAP'; | ||
+ | private $ssl = true; | ||
/** | /** | ||
Zeile 23: | Zeile 26: | ||
public function getEmails( $onlyUnread = false ) | public function getEmails( $onlyUnread = false ) | ||
{ | { | ||
- | $mailbox = sprintf( "{%s:143}INBOX", $this->server ); | + | $ssl = ''; |
+ | |||
+ | if( $this->ssl ) | ||
+ | { | ||
+ | $ssl = '/ssl'; | ||
+ | } | ||
+ | |||
+ | $mailbox = sprintf( "{%s:%d/%s%s/novalidate-cert}INBOX", $this->server, $this->port, $this->type, $ssl ); | ||
$this->stream = imap_open( $mailbox, $this->username, $this->password ); | $this->stream = imap_open( $mailbox, $this->username, $this->password ); | ||
$MC = imap_check( $this->stream ); | $MC = imap_check( $this->stream ); | ||
Zeile 100: | Zeile 110: | ||
---- | ---- | ||
- | ===== Beispiel für Dateianhänge ===== | + | ===== Beispiel für Dateianhänge (Attachments) ===== |
<code php> | <code php> | ||
Zeile 108: | Zeile 118: | ||
foreach( $emails as $email ) | foreach( $emails as $email ) | ||
{ | { | ||
- | $attamchent = $imap->getAttachments( $email->uid ); | + | $attachment = $imap->getAttachments( $email->uid ); |
- | if( $attamchent !== false ) | + | if( $attachment !== false ) |
{ | { | ||
- | echo "Anhang gefunden: " . $attamchent; | + | echo "Anhang gefunden: " . $attachment; |
} | } | ||
} | } | ||
</code> | </code> |