Showing posts with label windows. Show all posts
Showing posts with label windows. Show all posts

Windows Server - make network private

You can mark your network location on windows host as private just in three steps

1. Launch PowerShell as administrator
2. Get list of network interfaces (NICs) with command
Get-NetConnectionProfile

3. Change network category for selected network interface
Set-NetConnectionProfile -InterfaceIndex 15 -NetworkCategory Private


Enjoy!

HOWTO: send mail using perl on windows without sendmail

Q: How to send mail using perl on windows without sendmail?
A: You need Mail::Sender module and available SMTP Server

e.g.
Simple single part message
        $sender = new Mail::Sender {
                smtp => 'mail.yourISP.com',
                from => 'somebody@somewhere.com',
                on_errors => undef,
        }
                or die "Can't create the Mail::Sender object\n";
        $sender->Open({
                to => 'mama@home.org, papa@work.com',
                cc => 'somebody@somewhere.com',
                subject => 'Sorry, I\'ll come later.'
        })
                or die "Can't open the message: $sender->{'error_msg'}\n";
        $sender->SendLineEnc("I'm sorry, but thanks to the lusers,
                I'll come at 10pm at best.");
        $sender->SendLineEnc("\nHi, Jenda");
        $sender->Close()
                or die "Failed to send the message: $sender->{'error_msg'}\n";


read more here

yet another good option is Email::Sender module
usage:

  my $message = Email::MIME->create( ... );
  # produce an Email::Abstract compatible message object,
  # e.g. produced by Email::Simple, Email::MIME, Email::Stuff

  use Email::Sender::Simple qw(sendmail);
  use Email::Sender::Transport::SMTP qw();
  use Try::Tiny;

  try {
    sendmail(
      $message,
      {
        from => $SMTP_ENVELOPE_FROM_ADDRESS,
        transport => Email::Sender::Transport::SMTP->new({
            host => $SMTP_HOSTNAME,
            port => $SMTP_PORT,
        })
      }
    );
  } catch {
      warn "sending failed: $_";
  };

Simplemail for Windows

I need sometimes to send email from windows command line. I could not find appropriate light sendmail utility and has developed own simple tool. It requires at least  .NET 2.0 installed on the system.
simplemail is available here

Usage:
simplemail.exe [-a file] [-F file] [-H file] [-s subj] [-b addr] [-c addr] addr [...]

OPTIONS
-a file
Attach a file to your message using MIME.

-b address
Specify a blind-carbon-copy (BCC) recipient

-c address
Specify a carbon-copy (CC) recipient

-F config
Specify an initialization file to read

-h Show help.

-H draft
Specify a draft file which contains header and body
to use to send a message.

-s subject
Specify the subject of the message.

-v Show version.


If you are looking how to install SMTP (Simple Mail Transfer Protocol) in Windows answer is here.

Asterisk AST_SORCERY function

 AST_SORCERY gets a field from a sorcery object. Sorcery is always created for PJSIP aors, endpoints and identifies in asterisk. It allows y...