I have to use stunnel with postfix in order to achieve TLS wrapper mode for sending mails. Each time after booting, mails get deferred instead of sent. This continues to happen until I run '/etc/init.d/stunnel4 restart'. From then on, mails are sent successfully.
The stunnel4 and postfix startup scripts are installed as S21stunnel4 and S22postfix. Perhaps the solution would be to change the stunnel4 script to S23stunnel4 instead, so as to change the order of their startup? (I haven't yet tried this, so I don't know.)
My postfix configuration file is as follows.
/etc/postfix/main.cf:
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
biff = no
append_dot_mydomain = no
readme_directory = no
#=====Options for using stunnel wrapper for TLS=======
smtp_use_tls = no
smtp_enforce_tls = no
relayhost = [127.0.0.1]:11125
#=====End stunnel Options=======
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options =
smtp_sasl_auth_soft_bounce = no
myhostname = abcdefg
alias_maps = hash:/etc/aliases
alias_database = hash:/etc/aliases
mydestination = abcdefg, localhost.localdomain, localhost
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
mailbox_command = procmail -a "$EXTENSION"
mailbox_size_limit = 0
recipient_delimiter =
inet_interfaces = all
inet_protocols = ipv4