Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3391910
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:51:30+00:00 2026-05-18T03:51:30+00:00

I am trying to set up this script for my local bands newsletter. Currently,

  • 0

I am trying to set up this script for my local bands newsletter.

Currently, someone sends an email with a request to be added, we manually add it to newsletter mailer I set up.
(Which works great thanks to help I found here!)

The intent now is to have my script below log into the email account I set up for the list on our server, grab the info to add the email automatically.

I know there are a bunch of apps that do this but, I want to learn myself.

I already have the "add to list" working when there is an email address returned from the header(from) below BUT, sometimes the header(from) is a name and not the email address (eg "persons name" is returned from persons name<email@address> but, not the <email@address>.)

Now, I am not set in stone on the below method but, it works famously… to a point.

I read all the docs on these modules and there was nothing I could find to get the darn email in there all the time.

Can someone help me here? Verbose examples are greatly appreciated since I am struggling learning Perl.

 #!/usr/bin/perl -w
    ##########
    use CGI;
    use Net::IMAP::Simple;
    use Email::Simple;
    use IO::Socket::SSL; #optional i think if no ssl is needed
    use strict;
    use CGI::Carp qw(fatalsToBrowser warningsToBrowser);
    ######################################################
    # fill in your details here
    my $username = '#########';
    my $password = '#############';
    my $mailhost = '##############';
    #######################################################
    print CGI::header();
    # Connect
    my $imap = Net::IMAP::Simple->new($mailhost, port=> 143, use_ssl => 0, ) || die "Unable to connect to IMAP: $Net::IMAP::Simple::errstr\n";
    # Log in
     if ( !$imap->login( $username, $password ) ) {
      print STDERR "Login failed: " . $imap->errstr . "\n";
      exit(64);
     }
    # Look in the INBOX
    my $nm = $imap->select('INBOX');
    # How many messages are there?
    my ($unseen, $recent, $num_messages) = $imap->status();
    print "unseen: $unseen, <br />recent: $recent, <br />total: $num_messages<br />\n\n";
    ## Iterate through unseen messages
     for ( my $i = 1 ; $i <= $nm ; $i++ ) {
         if ( $imap->seen($i) ) {
         my $es = Email::Simple->new( join '', @{ $imap->top($i) } );
         printf( "[%03d] %s\n\t%s\n", $i, $es->header('From'), $es->header('Subject'));
         print "<br />";
         next;
         }## in the long version these are pushed into different arrays for experimenting purposes
       else {
       my $es = Email::Simple->new( join '', @{ $imap->top($i) } );
       printf( "[%03d] %s\n\t%s\n", $i, $es->header('From'), $es->header('Subject'));
       print "<br />";
       }
     }
    # Disconnect
    $imap->quit;
    exit;
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:51:30+00:00Added an answer on May 18, 2026 at 3:51 am
    use Email::Address;
    my @addresses = Email::Address->parse('persons name <email@address>');
    print $addresses[0]->address;
    

    The parse method returns an array, so the above way works for me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to set up the svn commit with trac using this script. It is
I'm trying to make a HTTP request from a Adobe Illustrator Script (this question
I'm trying to set this up where the user gives username and password in-app,
I'll try my best to explain how I'm trying to set up this system.
Afternoon, How would i set this as not equal to? I am basically trying
This is my first time trying to set up a database. My intent is
I'm trying to set the background color of a UIImageView with this (It should
I am trying to set an application icon (python3 / tkinter) like this: Interface()
I'm trying to set a function to do something like this def __binaryTreeInsert(self, toInsert,
I'm trying to set an image as the background using this code: root.setStyle(-fx-background-image: url('splash.jpg');

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.