Web Hosting Talk







View Full Version : Using sendmail from perl on cpanel(exim 4) server


freakysid
07-15-2003, 03:15 AM
Hello

1) Why doesn't this work

#!/usr/bin/perl


# send an email to notify an order has been received
open(MAIL, "|/usr/sbin/sendmail -t") || return 0;

select (MAIL);
print << "EOF";
To: bar@foobar.com
From: foobar@foo.com
Subject: Order Received

$time

EOF

The mail gets sent to bar@foobar.com@<host_name>
where <hostname> is the name of the server

Also, what are the correct flags for exim's sendmail accessed from a script like this?

Thanks
:)

Eric Lim
07-15-2003, 05:10 AM
#!/usr/bin/perl


# send an email to notify an order has been received
open(MAIL, "|/usr/sbin/exim -t") || return 0;

select (MAIL);
print << "EOF";
To: bar\@foobar.com
From: foobar\@foo.com
Subject: Order Received

$time

EOF

This should work, I had a quick test on my machine and it worked. :)

freakysid
07-15-2003, 06:59 AM
Hi - thanks for that. Well sendmail is just a link to exim but I noticed you had escaped the @ character in the string you sent to sendmail. Beauty! See I am not a perl guy so I really didn't know the answer.

cheers
:)

Eric Lim
07-15-2003, 07:12 AM
Well, I didn't know the answer as well. After reading some exim documentation and have this figured out.

Glad it works out. :)