connecting to a mail server via IMAP

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default connecting to a mail server via IMAP

    Can perl connect to a mail server via imap and then send some emails (with attachements of course)
    John Guest

  2. Similar Questions and Discussions

    1. #40420 [NEW]: --with-imap fails for imap-2004g from University of Washington IMAP toolkit
      From: romanf at trash dot net Operating system: Suse Linux 10.0 64bit PHP version: 5.2.1 PHP Bug Type: Compile Failure Bug...
    2. Geting Mail Messages From IMAP to UNIX mail file ???
      I need a solution to get messages from IMAP server transfered over to my server. Once the transfer complete I want to be able to read them. And one...
    3. moving mail to imap
      Hey all.. I use mozilla mail for my email.. and (at the moment) I have about 15,000 emails in my "Local Folders".. they are all in...
    4. #24846 [Opn->Fbk]: IMAP Mail functions are extremely slow
      ID: 24846 Updated by: wez@php.net Reported By: gremlinx at speed-city dot com -Status: Open +Status: ...
    5. #24846 [Opn]: IMAP Mail functions are extremely slow
      ID: 24846 User updated by: gremlinx at speed-city dot com Reported By: gremlinx at speed-city dot com Status: Open...
  3. #2

    Default Re: connecting to a mail server via IMAP

    Has perl its own smpt to send mails?

    ----- Original Message -----
    From: "David le Blanc" <com.au>
    To: "John" <uoi.gr>
    Sent: Tuesday, February 17, 2004 1:25 PM
    Subject: RE: connecting to a mail server via IMAP

     

    John Guest

  4. #3

    Default Re: connecting to a mail server via IMAP


    John wrote: 

    John wrote: 

    Hi John.

    You need Mail::IMAPClient and Net::SMTP.

    HTH,

    Rob


    Rob Guest

  5. #4

    Default Re: connecting to a mail server via IMAP

    So, could we send attachments using the Mail::IMAPClient?

    ----- Original Message -----
    From: "Rob Dixon" <port995.com>
    To: <org>
    Sent: Tuesday, February 17, 2004 2:41 PM
    Subject: Re: connecting to a mail server via IMAP

     
    >
    > John wrote: 
    >
    > Hi John.
    >
    > You need Mail::IMAPClient and Net::SMTP.
    >
    > HTH,
    >
    > Rob
    >
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]

    John Guest

  6. #5

    Default Re: connecting to a mail server via IMAP

    John wrote: 
    > >
    > > John wrote: 
    > >
    > > Hi John.
    > >
    > > You need Mail::IMAPClient and Net::SMTP.[/ref]
    >
    > So, could we send attachments using the Mail::IMAPClient?[/ref]

    Sorry John, I misread your first post. You can't use IMAP to send anything: it's
    a mail access protocol. You need SMTP.

    Rob


    Rob Guest

  7. #6

    Default Re: connecting to a mail server via IMAP

    I tried to connect to an imap server via the sample script that
    Mail::IMAPClient document provides and i recieved the following error.


    Mail::IMAPClient not using Fast_IO; not available on this platform at
    imap_test.pl line 15


    ----- Original Message -----
    From: "John" <uoi.gr>
    To: "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 2:56 PM
    Subject: Re: connecting to a mail server via IMAP

     
    > >
    > > John wrote: 
    > >
    > > Hi John.
    > >
    > > You need Mail::IMAPClient and Net::SMTP.
    > >
    > > HTH,
    > >
    > > Rob
    > >
    > >
    > >
    > > --
    > > To unsubscribe, e-mail: org
    > > For additional commands, e-mail: org
    > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    > >
    > >
    > >[/ref]
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    John Guest

  8. #7

    Default Re: connecting to a mail server via IMAP

    Using Net::SMTP can i send an email from my machine? Or Net::SMTP will
    enable to me to connect to a mail server and send email with attachements?

    ----- Original Message -----
    From: "Rob Dixon" <port995.com>
    To: <org>
    Sent: Tuesday, February 17, 2004 3:10 PM
    Subject: Re: connecting to a mail server via IMAP

     
    > >
    > > So, could we send attachments using the Mail::IMAPClient?[/ref]
    >
    > Sorry John, I misread your first post. You can't use IMAP to send[/ref]
    anything: it's 


    John Guest

  9. #8

    Default RE: connecting to a mail server via IMAP

    I don't think you can send attachments using Net::SMTP.

    Use Mail::Sender by Jenda Krynicky....it works !

    And what's best is that Jenda is always around in this list raring to
    help...so u've got real time support ;-)

    And yes you do indeed need a mail server to connect to...

    Cheers
    -aman

    -----Original Message-----
    From: John [mailto:uoi.gr]
    Sent: 17 February 2004 18:54
    To: Perl Beginners
    Subject: Re: connecting to a mail server via IMAP


    Using Net::SMTP can i send an email from my machine? Or Net::SMTP will
    enable to me to connect to a mail server and send email with attachements?

    ----- Original Message -----
    From: "Rob Dixon" <port995.com>
    To: <org>
    Sent: Tuesday, February 17, 2004 3:10 PM
    Subject: Re: connecting to a mail server via IMAP

     
    > >
    > > So, could we send attachments using the Mail::IMAPClient?[/ref]
    >
    > Sorry John, I misread your first post. You can't use IMAP to send[/ref]
    anything: it's 



    --
    To unsubscribe, e-mail: org
    For additional commands, e-mail: org
    <http://learn.perl.org/> <http://learn.perl.org/first-response>

    Aman Guest

  10. #9

    Default Re: connecting to a mail server via IMAP

    Is it neseccary to authenticate the smtp host?

    testing the first sample script i saw no results.

    Where is the problem?


    ----- Original Message -----
    From: "Thind, Aman" <co.in>
    To: "'John'" <uoi.gr>
    Cc: "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 3:42 PM
    Subject: RE: connecting to a mail server via IMAP

     
    > >
    > > Sorry John, I misread your first post. You can't use IMAP to send[/ref]
    > anything: it's 
    >
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    John Guest

  11. #10

    Default Re: connecting to a mail server via IMAP

    --As of Tuesday, February 17, 2004 4:17 PM +0200, John is alleged to have
    said:
     

    It depends on the host. ;-)
     

    We'll need more information than that... I assume you were trying to mail
    to an address you can check, from an address you can check? If it got
    through, there is no notification, and many errors would result in a bounce.

    Otherwise, if we could see the code you tried we could help.

    Daniel T. Staal

    ---------------------------------------------------------------
    This email copyright the author. Unless otherwise noted, you
    are expressly allowed to retransmit, quote, or otherwise use
    the contents for non-commercial purposes. This copyright will
    expire 5 years after the author's death, or in 30 years,
    whichever is longer, unless such a period is in excess of
    local copyright law.
    ---------------------------------------------------------------
    Daniel Guest

  12. #11

    Default Re: connecting to a mail server via IMAP

    Here is my code

    #!/usr/bin/perl -w

    use Mail::Sender;
    $sender = new Mail::Sender({smtp => 'mymailserver', from =>
    'john@mymailserver'});
    $sender->MailFile({to => 'john2@mymailserver',
    subject => 'Here is the file',
    msg => "I'm sending you the list you wanted."});


    john, john2 usernames exist on the mymailserver (it runs ESMTP Sendmail
    8.9.3/8.9.3)









    ----- Original Message -----
    From: "Daniel Staal" <net>
    To: "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 4:47 PM
    Subject: Re: connecting to a mail server via IMAP

     
    >
    > It depends on the host. ;-)

    >
    > We'll need more information than that... I assume you were trying to mail
    > to an address you can check, from an address you can check? If it got
    > through, there is no notification, and many errors would result in a[/ref]
    bounce. 


    John Guest

  13. #12

    Default Re: connecting to a mail server via IMAP

    Please bottom post, this thread is impossible to follow now...
     

    Let's back up a bit and understand the fundamentals before trying to
    wrangle the world of e-mail.

    SMTP allows us to transfer messages, messages have a header and a body.
    An attachment is a specialized part of a body. Net::SMTP provides the
    means to access the more raw portion of sending a message, aka
    connecting to and talking with an SMTP server. There is not a built in
    Perl SMTP server (as that isn't a language's job). Net::SMTP is the
    most direct way to send a message, and one of the uglier ways. So you
    can send a message with attachments using Net::SMTP, you just won't want
    to because you will have to know how to build it, which isn't easy.
    Therefore you should use any of the numerous modules from CPAN to handle
    the message building for you, Mail::Sender is a good one that has been
    suggested, there are also the MIME-Tools, and Mail::Message (this has a
    steep learning curve), among tens of others.

    As for your message about authenticating to use SMTP that depends on the
    host and we can't tell you about its configuration, talk to the admin
    about it. Net::SMTP does provide the 'auth' method for doing authentication.

    On the other side there is the delivery and access of messages through a
    server. IMAP is one of these protocols, POP is another, etc. There are
    at least two modules for reading from an IMAP server, Mail::IMAPClient
    and Mail::Box (Mail::Message is part of this distro). I see that you
    have tried the IMAPClient module, the message you posted is a warning
    not an error.

    Check out http://search.cpan.org for mail modules, there are loads of them.

    http://danconia.org
     
    > >
    > > Sorry John, I misread your first post. You can't use IMAP to send[/ref]
    > anything: it's 
    >
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    Wiggins Guest

  14. #13

    Default Re: connecting to a mail server via IMAP

    Hello,

    First of all i use perl for windows.

    Well, i what i really want to do is the following


    There is an SMTP Server
    There is a File Keeper Server (unix)
    There are some hosts (win32)


    The program i want to be able to send an email from the SMTP server
    attaching some files from the File Keepr Server.
    All that process i want to be done by the program running on a win32 system.




    ----- Original Message -----
    From: "Wiggins d Anconia" <org>
    To: "John" <uoi.gr>; "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 5:08 PM
    Subject: Re: connecting to a mail server via IMAP

     [/ref]
    attachements? 
    >
    > Let's back up a bit and understand the fundamentals before trying to
    > wrangle the world of e-mail.
    >
    > SMTP allows us to transfer messages, messages have a header and a body.
    > An attachment is a specialized part of a body. Net::SMTP provides the
    > means to access the more raw portion of sending a message, aka
    > connecting to and talking with an SMTP server. There is not a built in
    > Perl SMTP server (as that isn't a language's job). Net::SMTP is the
    > most direct way to send a message, and one of the uglier ways. So you
    > can send a message with attachments using Net::SMTP, you just won't want
    > to because you will have to know how to build it, which isn't easy.
    > Therefore you should use any of the numerous modules from CPAN to handle
    > the message building for you, Mail::Sender is a good one that has been
    > suggested, there are also the MIME-Tools, and Mail::Message (this has a
    > steep learning curve), among tens of others.
    >
    > As for your message about authenticating to use SMTP that depends on the
    > host and we can't tell you about its configuration, talk to the admin
    > about it. Net::SMTP does provide the 'auth' method for doing[/ref]
    authentication. 
    them. 
    > > anything: it's 
    > >
    > >
    > >
    > > --
    > > To unsubscribe, e-mail: org
    > > For additional commands, e-mail: org
    > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    > >
    > >
    > >[/ref]
    >
    >[/ref]


    John Guest

  15. #14

    Default Re: connecting to a mail server via IMAP

    --As of Tuesday, February 17, 2004 4:58 PM +0200, John is alleged to have
    said:
     

    Thanks. ;-)
     

    use strict;
     

    Well, you are missing a 'send' call; Mail::Sender has several you can
    choose from, depending on your needs.

    By the way, as others pointed out Mail::Sender is very low-level. I would
    suggest a higher level module here. MIME::Lite is highly regarded, and
    often overlooked while searching...

    Daniel T. Staal

    ---------------------------------------------------------------
    This email copyright the author. Unless otherwise noted, you
    are expressly allowed to retransmit, quote, or otherwise use
    the contents for non-commercial purposes. This copyright will
    expire 5 years after the author's death, or in 30 years,
    whichever is longer, unless such a period is in excess of
    local copyright law.
    ---------------------------------------------------------------
    Daniel Guest

  16. #15

    Default Re: connecting to a mail server via IMAP

    Unfortunately, MIME::Lite requires Sendmail on the host.


    ----- Original Message -----
    From: "Daniel Staal" <net>
    To: "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 5:26 PM
    Subject: Re: connecting to a mail server via IMAP

     
    >
    > Thanks. ;-)

    >
    > use strict;

    >
    > Well, you are missing a 'send' call; Mail::Sender has several you can
    > choose from, depending on your needs.
    >
    > By the way, as others pointed out Mail::Sender is very low-level. I would
    > suggest a higher level module here. MIME::Lite is highly regarded, and
    > often overlooked while searching...
    >
    > Daniel T. Staal
    >
    > ---------------------------------------------------------------
    > This email copyright the author. Unless otherwise noted, you
    > are expressly allowed to retransmit, quote, or otherwise use
    > the contents for non-commercial purposes. This copyright will
    > expire 5 years after the author's death, or in 30 years,
    > whichever is longer, unless such a period is in excess of
    > local copyright law.
    > ---------------------------------------------------------------
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    John Guest

  17. #16

    Default Re: connecting to a mail server via IMAP

    --As of Tuesday, February 17, 2004 5:53 PM +0200, John is alleged to have
    said:
     

    --As for the rest, it is mine.

    Actually, no. It just uses it by default... You can say:
    $msg->send('smtp'); #Uses the default smtp server.
    or:
    $msg->send('smtp', 'host.com'); #Uses host.com.

    Daniel T. Staal

    ---------------------------------------------------------------
    This email copyright the author. Unless otherwise noted, you
    are expressly allowed to retransmit, quote, or otherwise use
    the contents for non-commercial purposes. This copyright will
    expire 5 years after the author's death, or in 30 years,
    whichever is longer, unless such a period is in excess of
    local copyright law.
    ---------------------------------------------------------------
    Daniel Guest

  18. #17

    Default Re: connecting to a mail server via IMAP

    Things getting better :)

    But what is the difference in Path and FileName in the attachment method?


    ----- Original Message -----
    From: "Daniel Staal" <net>
    To: "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 6:10 PM
    Subject: Re: connecting to a mail server via IMAP

     
    >
    > --As for the rest, it is mine.
    >
    > Actually, no. It just uses it by default... You can say:
    > $msg->send('smtp'); #Uses the default smtp server.
    > or:
    > $msg->send('smtp', 'host.com'); #Uses host.com.
    >
    > Daniel T. Staal
    >
    > ---------------------------------------------------------------
    > This email copyright the author. Unless otherwise noted, you
    > are expressly allowed to retransmit, quote, or otherwise use
    > the contents for non-commercial purposes. This copyright will
    > expire 5 years after the author's death, or in 30 years,
    > whichever is longer, unless such a period is in excess of
    > local copyright law.
    > ---------------------------------------------------------------
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    John Guest

  19. #18

    Default Re: connecting to a mail server via IMAP

    PLEASE, bottom post...
     

    Path is the location of the file on the local file system, FileName is
    used in the content-disposition header for providing a suggested name
    for the file on the recipient's end which may or may not be used or even
    seen depending on the client. See told you, you didn't want to wrangle
    mail yourself :-)...

    http://danconia.org
     [/ref]
    have 
    > >
    > > --As for the rest, it is mine.
    > >
    > > Actually, no. It just uses it by default... You can say:
    > > $msg->send('smtp'); #Uses the default smtp server.
    > > or:
    > > $msg->send('smtp', 'host.com'); #Uses host.com.
    > >
    > > Daniel T. Staal
    > >
    > > ---------------------------------------------------------------
    > > This email copyright the author. Unless otherwise noted, you
    > > are expressly allowed to retransmit, quote, or otherwise use
    > > the contents for non-commercial purposes. This copyright will
    > > expire 5 years after the author's death, or in 30 years,
    > > whichever is longer, unless such a period is in excess of
    > > local copyright law.
    > > ---------------------------------------------------------------
    > >
    > > --
    > > To unsubscribe, e-mail: org
    > > For additional commands, e-mail: org
    > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    > >
    > >
    > >[/ref]
    >
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    Wiggins Guest

  20. #19

    Default Re: connecting to a mail server via IMAP

    From: Daniel Staal <net> 
    >
    > Thanks. ;-)

    >
    > use strict;

    >
    > Well, you are missing a 'send' call; Mail::Sender has several you can
    > choose from, depending on your needs.[/ref]

    Actually not. The MailFile method does create and send the message,
    no need for any further method calls.

    The problem is that John did not check for errors.

    The easiest way (IMHO) is to ask Mail::Sender to throw an exception
    if there is a problem:

    $sender = new Mail::Sender({
    smtp => 'mymailserver',
    from => 'john@mymailserver',
    on_errors => 'die',
    });
     

    I think you confuse Mail::Sender and Net::SMTP. Mail::Sender and
    MIME::Lite is at about the same level.

    The big difference is in the philosophy of the modules.
    In MIME::Lite you are constructing a message and then when it's
    complete, with all the parts and files, you send it as one object.
    In MIME::Lite the message is the object.

    OTOH in Mail::Sender, you are controling a mail agent, you tell it to
    connect to a server and start a multipart mail, then you tell it what
    to send as the body, what file to attach and then to close the
    message. And the sender does each of those actions immediately.
    (Except if you use the MailMsg or MailFile shortcuts that do all
    these actions behind the scenes.)

    Which means Mail::Sender uses less memory if you are attaching big
    files, but if you need more complex multipart messages its interface
    is not that nice. And overall Mail::Sender is a bit dirtier :-)

    Jenda
    ===== cz === http://Jenda.Krynicky.cz =====
    When it comes to wine, women and song, wizards are allowed
    to get drunk and croon as much as they like.
    -- Terry Pratchett in Sourcery

    Jenda Guest

  21. #20

    Default Re: connecting to a mail server via IMAP

    Relaying denied.


    What is that?

    Could i connect to any smtp server i want.

    Please enlighten me!


    ----- Original Message -----
    From: "Wiggins d Anconia" <org>
    To: "John" <uoi.gr>; "Perl Beginners" <org>
    Sent: Tuesday, February 17, 2004 6:40 PM
    Subject: Re: connecting to a mail server via IMAP

     [/ref]
    method? 
    >
    > Path is the location of the file on the local file system, FileName is
    > used in the content-disposition header for providing a suggested name
    > for the file on the recipient's end which may or may not be used or even
    > seen depending on the client. See told you, you didn't want to wrangle
    > mail yourself :-)...
    >
    > http://danconia.org
    > [/ref]
    > have 
    > >
    > >
    > >
    > > --
    > > To unsubscribe, e-mail: org
    > > For additional commands, e-mail: org
    > > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    > >
    > >
    > >[/ref]
    >
    >
    >
    > --
    > To unsubscribe, e-mail: org
    > For additional commands, e-mail: org
    > <http://learn.perl.org/> <http://learn.perl.org/first-response>
    >
    >
    >[/ref]


    John Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139