Congratulations for making the switch to postfix, it's a very capable mailer.

I'm not sure that that you've read all the documentation, because I think you'll find that postfix provides a complete sendmail drop-in replacement. You think you're talking to the sendmail binary, but it fact postfix has replaced it with its own version, that connects to the postfix backend. In theory the change should be transparent. Can you describe the problems you are having?

I note that you are not testing whether you actually succeed in opening the pipe to your mailer. You should do something like:

open (MAIL, "|$mail_prog -t") or die "Could not open output pipe to $mail_prog: $!\n";

Secondly, beware of the marching print statements. Use a here-doc or a template system (if you want to get fancy). A here-doc looks like this:

print MAIL <<MAIL_MESSAGE; To: $recip Reply-to: $email From: $email Subject: Blah Display Name: $display Username: $username Password: $password Domain: $domain Updates: $service IP: $ip MAIL_MESSAGE

In fact, having cleaned up your code, I realise you were using double-quoted strings, hence subject to interpolation, but instead of interpolating variables, you were manually concatenating strings and variables, thus getting the worst of both worlds (in terms of readability). All those extra tokens are just syntax errors waiting to happen.

Finally, you are better off using a module that does some level of encapsulation of sending e-mail, be it Mimetools, Mail::Sendmail or even Net::SMTP. If you used one of these modules, it would matter even less to your script what MTA (Mail Transfer Agent) was in use.

Hope this helps.


print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'

In reply to Re: Postfix Sending Mail by grinder
in thread Postfix Sending Mail by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.