Fetch messages and save them in $spool_file.
514{
516 if (!c_pop_host)
517 {
519 return;
520 }
521
522 char buf[1024] = { 0 };
523 char msgbuf[128] = { 0 };
524 int last = 0, msgs = 0, bytes = 0, rset = 0, rc;
526
528 char *url = p;
530 {
531 strcpy(url, "pop://");
532 p = strchr(url, '\0');
533 }
534 strcpy(p, c_pop_host);
535
538 if (rc)
539 {
540 mutt_error(
_(
"%s is an invalid POP path"), c_pop_host);
541 return;
542 }
543
545 if (!conn)
546 return;
547
550
552 {
554 return;
555 }
556
558
559
562 if (rc == -1)
563 goto fail;
564 if (rc == -2)
565 {
567 goto finish;
568 }
569
570 sscanf(buf, "+OK %d %d", &msgs, &bytes);
571
572
574 if ((msgs > 0) && c_pop_last)
575 {
578 if (rc == -1)
579 goto fail;
580 if (rc == 0)
581 sscanf(buf, "+OK %d", &last);
582 }
583
584 if (msgs <= last)
585 {
587 goto finish;
588 }
589
592
594 {
596 goto finish;
597 }
598 bool old_append = m_spool->
append;
600
603
604 snprintf(msgbuf, sizeof(msgbuf),
605 ngettext("Reading new messages (%d byte)...",
606 "Reading new messages (%d bytes)...", bytes),
607 bytes);
609
610 for (int i = last + 1; i <= msgs; i++)
611 {
613 if (msg)
614 {
615 snprintf(buf, sizeof(buf), "RETR %d\r\n", i);
617 if (rc == -3)
618 rset = 1;
619
621 {
622 rset = 1;
623 rc = -3;
624 }
625
627 }
628 else
629 {
630 rc = -3;
631 }
632
633 if ((rc == 0) && (delanswer ==
MUTT_YES))
634 {
635
636 snprintf(buf, sizeof(buf), "DELE %d\r\n", i);
638 }
639
640 if (rc == -1)
641 {
642 m_spool->
append = old_append;
644 goto fail;
645 }
646 if (rc == -2)
647 {
649 break;
650 }
651 if (rc == -3)
652 {
654 break;
655 }
656
657
658
660 "%s [%d of %d messages read]", msgs - last),
661 msgbuf, i - last, msgs - last);
662 }
663
664 m_spool->
append = old_append;
666
667 if (rset)
668 {
669
671 if (
pop_query(adata, buf,
sizeof(buf)) == -1)
672 goto fail;
673 }
674
675finish:
676
678 if (
pop_query(adata, buf,
sizeof(buf)) == -1)
679 goto fail;
682 return;
683
684fail:
688}
const char * cs_subset_string(const struct ConfigSubset *sub, const char *name)
Get a string config item by name.
void mailbox_free(struct Mailbox **ptr)
Free a Mailbox.
void pop_adata_free(void **ptr)
Free the private Account data - Implements Account::adata_free() -.
#define mutt_message(...)
void * mutt_mem_calloc(size_t nmemb, size_t size)
Allocate zeroed memory on the heap.
struct Connection * mutt_conn_find(const struct ConnAccount *cac)
Find a connection from a list.
int mx_msg_close(struct Mailbox *m, struct Message **ptr)
Close a message.
bool mx_mbox_open(struct Mailbox *m, OpenMailboxFlags flags)
Open a mailbox and parse it.
struct Message * mx_msg_open_new(struct Mailbox *m, const struct Email *e, MsgOpenFlags flags)
Open a new message.
int mx_msg_commit(struct Mailbox *m, struct Message *msg)
Commit a message to a folder - Wrapper for MxOps::msg_commit()
struct Mailbox * mx_path_resolve(const char *path)
Get a Mailbox for a path.
enum MxStatus mx_mbox_close(struct Mailbox *m)
Save changes and close mailbox.
#define MUTT_ADD_FROM
add a From_ line
#define MUTT_OPEN_NO_FLAGS
No flags are set.
struct PopAccountData * pop_adata_new(void)
Create a new PopAccountData object.
int pop_open_connection(struct PopAccountData *adata)
Open connection and authenticate.
int pop_parse_path(const char *path, struct ConnAccount *cac)
Parse a POP mailbox name.
QuadOption
Possible values for a quad-option.
@ MUTT_YES
User answered 'Yes', or assume 'Yes'.
enum QuadOption query_quadoption(const char *prompt, struct ConfigSubset *sub, const char *name)
Ask the user a quad-question.
int mutt_socket_close(struct Connection *conn)
Close a socket.
Login details for a remote server.
bool append
Mailbox is opened in append mode.
A local copy of an email.
FILE * fp
pointer to the message data
enum UrlScheme url_check_scheme(const char *str)
Check the protocol of a URL.
@ U_UNKNOWN
Url wasn't recognised.