# Mail

```perl
#!/usr/bin/perl

$to = 'abcd@gmail.com';
$from = 'webmaster@yourdomain.com';
$subject = 'Test Email';
$message = 'This is a test email sent.';

open(MAIL, "|/usr/sbin/sendmail -t");

# Email Header
print MAIL "To: $to\n";
print MAIL "From: $from\n";
print MAIL "Subject: $subject\n\n";
# Email Body
print MAIL $message;

close(MAIL);
```

## Mail::Mailer

```perl
#!/usr/bin/perl
use warnings;
use strict;

use Mail::Mailer;

my $mailer = Mail::Mailer->new('sendmail');
my %headers = (
    'To' => 'you@example.com',
    'From' => 'me@example.com',
    'Subject' => 'Sample Mail'
);
$mailer->open(\%headers);
print $mailer "This is the message.\n";
$mailer->close;
```

- new

- open

- close


## Mail::Send

```perl
#!/usr/bin/perl
use warnings;
use strict;

use Mail::Send;

my $mail = Mail::Send->new;
$mail->set('To', ('you@example.com', 'another@example.com'));
$mail->to('you@example.com');
$mail->subject('Sample Mail');
my $fh = $mail->open('sendmail');
print $fh "This is the message.\n";
$fh->close or die $!;
```

- new

- open

- add

- delete

- set

- to

- cc

- bcc

- subject