Difference between revisions of "Email"
(4 intermediate revisions by the same user not shown) | |||
Line 11: | Line 11: | ||
If you want to add email to your PHP application or website, then use [https://github.com/PHPMailer/PHPMailer PHPMailer], [http://swiftmailer.org/ Swift Mailer] by SensioLabs, or other fine alternatives. Don't use PHP's <code>mail()</code> function unless you are really going for basic messaging to yourself only. You can also use Google's SMTP server to send but you'll still end up being dependent on the 'cleanliness' of your IP for delivery. | If you want to add email to your PHP application or website, then use [https://github.com/PHPMailer/PHPMailer PHPMailer], [http://swiftmailer.org/ Swift Mailer] by SensioLabs, or other fine alternatives. Don't use PHP's <code>mail()</code> function unless you are really going for basic messaging to yourself only. You can also use Google's SMTP server to send but you'll still end up being dependent on the 'cleanliness' of your IP for delivery. | ||
− | 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"> | <source lang="bash"> | ||
telnet smtp.gmail.com 25 | telnet smtp.gmail.com 25 | ||
Line 31: | Line 31: | ||
telnet> quit | telnet> quit | ||
Connection closed. | Connection closed. | ||
− | |||
</pre> | </pre> | ||
+ | Check your server IP with a tool like http://mxtoolbox.com/blacklists.aspx | ||
− | + | === My wiki won't send email === | |
+ | First, did you check if mail is working from PHP? | ||
+ | |||
+ | <source lang="php"> | ||
+ | <?php | ||
+ | $mailto = 'greg@eQuality-Tech.com'; | ||
+ | $subject = 'test mail'; | ||
+ | $message = 'sample message'; | ||
+ | $from = 'wiki@example.org'; | ||
+ | $header = "From:$from"; | ||
+ | if ( mail ( $mailto, $subject, $message, $header ) ) { | ||
+ | echo "Email sent\n"; | ||
+ | echo "Try 'sudo tail /var/log/mail.log' to look for other possible errors.\n"; | ||
+ | } | ||
+ | </source> | ||
− | |||
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 45: | Line 58: | ||
If you're not outsourcing everything through a third party, you'll want to implement [[SPF]] and [[DKIM]] and [[DMARC]]. Even if you're using a third-party like GAFYD, if you've got a [[CiviCRM]] instance managing all your constituent mailing, then you're going to need to setup these anti-spam measures. | If you're not outsourcing everything through a third party, you'll want to implement [[SPF]] and [[DKIM]] and [[DMARC]]. Even if you're using a third-party like GAFYD, if you've got a [[CiviCRM]] instance managing all your constituent mailing, then you're going to need to setup these anti-spam measures. | ||
+ | |||
+ | === How do I use the 'mail' command? === | ||
+ | You're on a linux server and you see "You've got mail". So, you type 'mail' and immediately have no idea how to process the messages. See this excellent tutorial/write-up of the basic '''mail''' command: http://www.johnkerl.org/doc/mail-how-to.html The <code>mail</code> command works like the editor '''<code>ed</code>''' which is to say not very well known today. (See <code>man mail</code> -- The manual page was written in 1993.) The man page refers to [https://docs.freebsd.org/44doc/usd/07.mail/paper.pdf The Mail Reference Manual] originally written by Kurt Shoens | ||
+ | |||
+ | === What is my mail server doing? === | ||
+ | <code>mailq</code> tells you about what's in the queue (What it's going to send). | ||
+ | |||
+ | Grepping the mail log can tell you where your server has sent mail. | ||
+ | <source lang="bash"> | ||
+ | grep --perl-regex --only-matching ' to=[^ ,]*' /var/log/maillog | awk -F= '{print $2}' | sort | uniq -c | ||
+ | </source> | ||
+ | |||
+ | |||
+ | <pre> | ||
+ | 37 admin@equality-tech.com\t | ||
+ | 305 meza-ansible | ||
+ | 305 <meza-ansible@my.qualitybox.us> | ||
+ | 35 root | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | |||
== Tools == | == Tools == |
Latest revision as of 09:55, 28 August 2018
eQuality Technology uses Google Apps For Your Domain (GAFYD) also referred to as GoogleApps, which includes mail services. eQuality Technology is a Google Apps consultant and is happy to help you with your Email services. See the Email Marketing page for information pertinent to managing things like newsletters, mailing lists, and bulk email marketing.
Contents
Users[edit | edit source]
Access mail in your web browser by visiting http://mail.eQuality-Tech.com [1]
Security / Privacy[edit | edit source]
You can't have privacy in your email unless you use a service like Kolab Now which is located outside the U.S. and uses encryption of the contents. [2]
HOWTO[edit | edit source]
My website needs a contact form[edit | edit source]
If you want to add email to your PHP application or website, then use PHPMailer, Swift Mailer by SensioLabs, or other fine alternatives. Don't use PHP's mail()
function unless you are really going for basic messaging to yourself only. You can also use Google's SMTP server to send but you'll still end up being dependent on the 'cleanliness' of your IP for delivery.
Make sure your server IP is not blacklisted or firewalled. Telnet to Google:
telnet smtp.gmail.com 25
# then
^] # get a telnet prompt with the Ctrl key plus right square bracket key
quit [enter]
So a successful test ends up looking like this:
$ telnet smtp.gmail.com 25 Trying 2607:f8b0:400d:c03::6d... Trying 64.233.171.108... Connected to smtp.gmail.com. Escape character is '^]'. 220 mx.google.com ESMTP b16sm2116075qga.48 - gsmtp ^] telnet> quit Connection closed.
Check your server IP with a tool like http://mxtoolbox.com/blacklists.aspx
My wiki won't send email[edit | edit source]
First, did you check if mail is working from PHP?
<?php
$mailto = 'greg@eQuality-Tech.com';
$subject = 'test mail';
$message = 'sample message';
$from = 'wiki@example.org';
$header = "From:$from";
if ( mail ( $mailto, $subject, $message, $header ) ) {
echo "Email sent\n";
echo "Try 'sudo tail /var/log/mail.log' to look for other possible errors.\n";
}
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 sudo apt-get install mailutils
. 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.
I need a server to send email[edit | edit source]
You can setup Postfix to send as an Internet Site. And you can even use it to send mail through an external service like GMail (called 'smart hosting'). Once you do, you certainly need to add or reconfigure your domains SPF record in DNS
If you're not outsourcing everything through a third party, you'll want to implement SPF and DKIM and DMARC. Even if you're using a third-party like GAFYD, if you've got a CiviCRM instance managing all your constituent mailing, then you're going to need to setup these anti-spam measures.
How do I use the 'mail' command?[edit | edit source]
You're on a linux server and you see "You've got mail". So, you type 'mail' and immediately have no idea how to process the messages. See this excellent tutorial/write-up of the basic mail command: http://www.johnkerl.org/doc/mail-how-to.html The mail
command works like the editor ed
which is to say not very well known today. (See man mail
-- The manual page was written in 1993.) The man page refers to The Mail Reference Manual originally written by Kurt Shoens
What is my mail server doing?[edit | edit source]
mailq
tells you about what's in the queue (What it's going to send).
Grepping the mail log can tell you where your server has sent mail.
grep --perl-regex --only-matching ' to=[^ ,]*' /var/log/maillog | awk -F= '{print $2}' | sort | uniq -c
37 admin@equality-tech.com\t 305 meza-ansible 305 <meza-ansible@my.qualitybox.us> 35 root
Tools[edit | edit source]
- http://mxtoolbox.com/ All of your MX record, DNS, blacklist and SMTP diagnostics in one integrated tool. Input a domain name or IP Address or Host Name. Links in the results will guide you to other relevant tools and information. And you'll have a chronological history of your results. The site will give you a complete diagnostic. For example: http://mxtoolbox.com/domain/equality-tech.com/
Issues[edit | edit source]
Users can be blocked for going over usage limits (messages per day, recipients per message, etc) 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
> /var/spool/mail/root
will truncate the mail file.
References[edit source]
- ↑ This is for internal users at eQuality Technology. If you manage email services for your company and want to offer your users a similarly easy to remember sub-domain, you can accomplish this by creating a cname (alias) record in your DNS
- ↑ http://lavabit.com/