Sending email using perl with sendmail -
i trying send email using sendmail in perl. email sent content send subject gets added 'to:' in email. example, if address from@gmail.com
, address to@gmail.com
, subject "test subject"
. email reply-to:
field from@gmail.com,"subject:test.email","to:to"@gmail.com,"content-type:text/plain"
here code:
open(sendmail, "|/usr/lib/sendmail -oi -t '$to_email' -f '$from_email'") || ($error_message .= "<p>unable open email process.</p>"); print sendmail $reply_to; print sendmail $subject; print sendmail $send_to; print sendmail "content-type: text/plain\n\n"; print sendmail $content; close(sendmail);
and if remove $reply_to , $send_to lines, email comes from:
field apache server.
any appreciated. not want use other library email::mime
since doesn't exist on system.
i not sure wrong show, here working code
my ($header, $from, $to, $cc, $replyto, $subject); $from = "from: $from"; $to = "to: $to"; $cc = "cc: $cc_addresses"; $replyto = "reply-to: $replyto"; $subject = "subject: $subj"; # form header. fields submitted: $header = join("\n", $from, $to, $replyto, $subject, ''); # optional fields $header .= "$cc\n" if $cc_addresses; open(sendmail, "|/usr/sbin/sendmail -oi -t") or carp "can't fork sendmail: $!\n"; sendmail "$header\n$msg_cont"; close(sendmail);
note. there my $cc_addresses = '';
earlier, (possibly) gets built up.
Comments
Post a Comment