Send email using Perl

N

Ning li

Hi,

I am new to Perl and I would like to know the Perl equivalent of this
Unix mail command:

mailx -s "My Subject Here" (e-mail address removed) < my_file_name

Thanks in advance.

Nick Li
 
M

Mina Naguib

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Ning said:
Hi,

I am new to Perl and I would like to know the Perl equivalent of this
Unix mail command:

mailx -s "My Subject Here" (e-mail address removed) < my_file_name

system qq|mailx -s "My Subject Here" (e-mail address removed) < my_file_name|;

or

`mailx -s "My Subject Here" (e-mail address removed) < my_file_name`;

or

open (FH, "| mailx") or die . .;
print to FH

or the best, perl-ish way :

perldoc Net::SMTP

Best of luck.


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE/Y9pMeS99pGMif6wRAggqAKCLN9K5lM5fzboinKZpr9WrymPeBgCgjBhT
wcLgZCyIeLgdcTK2tCyIaF8=
=EVL3
-----END PGP SIGNATURE-----
 
B

Bill Zhao

Ning li said:
Hi,

I am new to Perl and I would like to know the Perl equivalent of this
Unix mail command:

mailx -s "My Subject Here" (e-mail address removed) < my_file_name
in perl:
if (`mailx -s "My Subject Here" (e-mail address removed) < my_file_name`) {
die "Mail Send Fail ";
}
 
S

Sam Holden

in perl:
if (`mailx -s "My Subject Here" (e-mail address removed) < my_file_name`) {
die "Mail Send Fail ";
}

Did you even think about that for a second? Did you really want to
interpolate the array @mail into that command?

Why does mailx indicate failure by outputting to stdout? That seems like
a remarkably stupid way of indicating failure.

Of course it probably doesn't. It's far more likely you just don't know
how to execute a command correctly in perl...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top