Email: Difference between revisions

No edit summary
m Text replacement - "<(\/?)source" to "<$1syntaxhighlight"
 
Line 12: Line 12:


Make sure your server IP is not blacklisted or firewalled.  [[Telnet]] to Google:
Make sure your server IP is not blacklisted or firewalled.  [[Telnet]] to Google:
<source lang="bash">
<syntaxhighlight lang="bash">
telnet smtp.gmail.com 25
telnet smtp.gmail.com 25
# then  
# then  
^] # get a telnet prompt with the Ctrl key plus right square bracket key
^] # get a telnet prompt with the Ctrl key plus right square bracket key
quit [enter]
quit [enter]
</source>
</syntaxhighlight>


So a successful test ends up looking like this:
So a successful test ends up looking like this:
Line 38: Line 38:
First, did you check if mail is working from PHP?
First, did you check if mail is working from PHP?


<source lang="php">
<syntaxhighlight lang="php">
<?php
<?php
     $mailto = 'greg@eQuality-Tech.com';
     $mailto = 'greg@eQuality-Tech.com';
Line 50: Line 50:
         echo "Try 'sudo tail /var/log/mail.log' to look for other possible errors.\n";
         echo "Try 'sudo tail /var/log/mail.log' to look for other possible errors.\n";
     }
     }
</source>
</syntaxhighlight>


If your application already has email capability, but it won't send, then turn on the mail_log feature in php.ini and check that sendmail/postfix is installed on your system.  You might start with <code>sudo apt-get install mailutils</code>.  If on AWS or datacenter, you can set up as an internet site and be done.  If you are behind a consumer broadband IP, you will probably need to setup a 'smarthosted' site and use (your own) IMAP credentials to send email through another provider.
If your application already has email capability, but it won't send, then turn on the mail_log feature in php.ini and check that sendmail/postfix is installed on your system.  You might start with <code>sudo apt-get install mailutils</code>.  If on AWS or datacenter, you can set up as an internet site and be done.  If you are behind a consumer broadband IP, you will probably need to setup a 'smarthosted' site and use (your own) IMAP credentials to send email through another provider.
Line 66: Line 66:


Grepping the mail log can tell you where your server has sent mail.
Grepping the mail log can tell you where your server has sent mail.
<source lang="bash">
<syntaxhighlight lang="bash">
grep --perl-regex --only-matching ' to=[^ ,]*' /var/log/maillog | awk -F= '{print $2}' | sort | uniq -c
grep --perl-regex --only-matching ' to=[^ ,]*' /var/log/maillog | awk -F= '{print $2}' | sort | uniq -c
</source>
</syntaxhighlight>




Line 88: Line 88:
https://support.google.com/a/answer/166852?hl=en
https://support.google.com/a/answer/166852?hl=en


If you've been running a server for a long time, and you have no idea how it works, you might find that there are a LOT of messages in root's mailbox.  Standard mailboxes are in /var/spool/mail/USER so <source lang="bash"> > /var/spool/mail/root</source> will truncate the mail file.
If you've been running a server for a long time, and you have no idea how it works, you might find that there are a LOT of messages in root's mailbox.  Standard mailboxes are in /var/spool/mail/USER so <syntaxhighlight lang="bash"> > /var/spool/mail/root</syntaxhighlight> will truncate the mail file.


{{References}}
{{References}}