LukeSmithxyz / emailwiz

Script that installs/configures a Dovecot, Postfix, Spam Assassin, OpenDKIM Debian web server
GNU General Public License v3.0
1.82k stars 302 forks source link

Unable to send emails (yes, port 25 is unblocked on Vultr's end) #287

Closed ShweetsStuff closed 1 year ago

ShweetsStuff commented 1 year ago

Thunderbird: Sending of the message failed. The message could not be sent because connecting to Outgoing server (SMTP) mail.[my domain] failed. The server may be unavailable or is refusing SMTP connections. Please verify that your Outgoing server (SMTP) settings are correct and try again.

Port 25 isn't blocked. Asked Vultr to unblock it many moons ago, and testing it just as proof:

[me]:~# telnet portquiz.net 25

Trying 35.180.139.74...

Connected to portquiz.net.

Escape character is '^]'.

I figure the issue may be with Postfix, as the status says "active (exited)":

● postfix.service - Postfix Mail Transport Agent
     Loaded: loaded (/lib/systemd/system/postfix.service; enabled; vendor preset: enabled)
     Active: active (exited) since Thu 2023-07-06 02:33:08 UTC; 7min ago
   Main PID: 53006 (code=exited, status=0/SUCCESS)
      Tasks: 0 (limit: 1114)
     Memory: 0B
        CPU: 0
     CGroup: /system.slice/postfix.service

Jul 06 02:33:08 [my system name here] systemd[1]: Starting Postfix Mail Transport Agent...
Jul 06 02:33:08 [my system name here] systemd[1]: Finished Postfix Mail Transport Agent.

Receiving email works totally fine. Suddenly had this issue after months of using the email just fine. Any ideas? Might also be something with OpenDKIM, not sure.

runxiyu commented 1 year ago

/var/log/mail.err and journalctl -xeu postfix.service may be useful

ShweetsStuff commented 1 year ago

cat /var/log/mail.err:

Jul  7 01:59:04 [my hostname] spamd[7014]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_0
4006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu/
 1.
Jul  7 01:59:06 [my hostname] dovecot: master: Fatal: service(imap) access(/usr/lib/dovecot/imap) failed: No such file or directory
Jul  7 01:59:36 [my hostname] dovecot: master: Fatal: service(imap) access(/usr/lib/dovecot/imap) failed: No such file or directory
Jul  7 02:01:34 [my hostname] spamd[16102]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_
04006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu
e 1.
Jul  7 02:01:36 [my hostname] spamd[16143]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_
04006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu
e 1.
Jul  7 02:20:09 [my hostname] opendkim[17545]: can't load key from /etc/postfix/dkim/mail.private: No such file or directory
Jul  7 02:20:09 [my hostname] opendkim[17545]: 7F1C6BC2: error loading key 'mail._domainkey.[my domain name]'
Jul  7 02:20:13 [my hostname] opendkim[17545]: can't load key from /etc/postfix/dkim/mail.private: No such file or directory
Jul  7 02:20:13 [my hostname] opendkim[17545]: 6BE7CBC2: error loading key 'mail._domainkey.[my domain name]

Not sure what the OpenDKIM stuff or the spamassassin stuff is about...

journalctl -xeu postfix.service:

Jul 07 01:32:18 [my host name] systemd[1]: Starting Postfix Mail Transport Agent...
░░ Subject: A start job for unit postfix.service has begun execution
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit postfix.service has begun execution.
░░
░░ The job identifier is 7016.
Jul 07 01:32:18 [my host name] systemd[1]: Finished Postfix Mail Transport Agent.
░░ Subject: A start job for unit postfix.service has finished successfully
░░ Defined-By: systemd
░░ Support: https://www.debian.org/support
░░
░░ A start job for unit postfix.service has finished successfully.
░░
░░ The job identifier is 7016.

Just sort of immediately starts and finishes, which I'm not sure.

On Thunderbird, SMTP port is set to 465.

runxiyu commented 1 year ago

On Fri Jul 7, 2023 at 2:24 AM UTC, Shweet wrote:

cat /var/log/mail.err:

Jul  7 01:59:04 [my hostname] spamd[7014]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_0
4006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu/
 1.
Jul  7 01:59:06 [my hostname] dovecot: master: Fatal: service(imap) access(/usr/lib/dovecot/imap) failed: No such file or directory
Jul  7 01:59:36 [my hostname] dovecot: master: Fatal: service(imap) access(/usr/lib/dovecot/imap) failed: No such file or directory
Jul  7 02:01:34 [my hostname] spamd[16102]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_
04006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu
e 1.
Jul  7 02:01:36 [my hostname] spamd[16143]: Can't locate Mail/SpamAssassin/CompiledRegexps/body_0.pm in @INC (you may need to install the Mail::SpamAssassin::CompiledRegexps::body_
04006/auto /usr/share/perl5 /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.32.1 /usr/local/share/perl/5.32.1 /usr/lib/x86_64-linux-gnu/perl5/5.32 /usr/lib/x86_64-linux-gnu
e 1.
Jul  7 02:20:09 [my hostname] opendkim[17545]: can't load key from /etc/postfix/dkim/mail.private: No such file or directory
Jul  7 02:20:09 [my hostname] opendkim[17545]: 7F1C6BC2: error loading key 'mail._domainkey.[my domain name]'
Jul  7 02:20:13 [my hostname] opendkim[17545]: can't load key from /etc/postfix/dkim/mail.private: No such file or directory
Jul  7 02:20:13 [my hostname] opendkim[17545]: 6BE7CBC2: error loading key 'mail._domainkey.[my domain name]

Your installation looks very broken. You may want to purge opendkim, spamassassin/spamd, postfix, and dovecot, along with all their configuration files, and reinstall with emailwiz. (Additionally, if you are planning to switch to Debian 12 bookworm, or if you're already on Bookworm, you may want to use this pull request too.

Not sure what the OpenDKIM stuff or the spamassassin stuff is about...

Don't know, seems that you have missing configuration files. See above.

On Thunderbird, SMTP port is set to 465.

I am unsure how this works, but my setup doesn't work with port 465 (with TLS) either. When using external SMTP clients, I use port 587 with STARTTLS.

The following is an example MSMTP configuration that works for me as I do not use Thunderbird:

account ***@***.***
host mail.example.org
port 587
from ***@***.***
user ***@***.***
passwordeval "pass ***@***.***"
auth on
tls on
tls_trust_file  /etc/ssl/certs/ca-certificates.crt

Hope this helps.

ShweetsStuff commented 1 year ago

Purged (apt purge): opendkim postfix dovecot-imapd dovecot-sieve opendkim spamassassin spamc opendkim-tools

Removed (rm -rf): /etc/postfix /etc/opendkim /etc/spamassassin /etc/dovecot

Ran emailwiz.sh.

Copied information from ~/dns_emailwizard to my MX records, verbatim.

Tested 465. Hangs on "Sending message..." until eventually erroring out.

Tested 587. Immediately throws this error:

Sending of the message failed. An error occurred while sending mail. The mail server responded: Service unavailable - try again later. Please check the message and try again.

Emailing to just a gmail account, nothing more.

Currently sticking with Debian 11, as it stands.

I think it'd be useful to have an uninstall script for retards like me, tbh. I've "reinstalled" multiple times by 1) purging all the packages, and 2) hunting down all the files I can with "postfix", "spamassassin", "dovecot", etc. and deleting them, but maybe I'm just not being comprehensive enough.

runxiyu commented 1 year ago

spamd and opendkim

ShweetsStuff commented 1 year ago

Ultimately, this just seems like an issue with my server - it's currently got Debian 11 and the new hotness is 12, with this script being updated for it. I'll save everyone some headaches on this issue and just reinstall everything, as much as a burden as that is; that will probably solve the problem.