1

I have a G Suite account and want to use the Google's SMTP to send out emails from my server.

How can I then send emails from Linux's CLI? I read with some research that I need a program such as Sendmail, which is an MTA. What I don't get, is the reason why I need to install a mail server, while what I want is to use the SMTP server of Google to send out emails, not my server. What will my server's MTA then really do if I want to use Google's SMTP?

Secondly, if I use Google's SMTP from my server, does that mean for the mail recipient that Google's server sent the email or my server sent the email? Which server address should the SPF record include?

  • The Q&A platform works better if you limit each question to only a specific issue , setting up correct SPF records is quite a different topic – HBruijn Apr 3 at 12:31
3

You don't need a (light-weight) MTA on your server when all applications that need to send email messages have native SMTP support and be configured to use an external SMTP server.

That is probably not the case: because rather than configuring all individual applications separately with MTA settings the conventional / classic Linux behavior is that you configure the host to send email. Once the host is configured correctly, then all applications on that host can call on /var/lib/sendmail (which, a long time in the past, would actually have been sendmail but nowadays all more modern replacements like Postfix, Exim etc. provide their own replacement sendmail compatible stubs there instead) to send outgoing email. No configuration of individual applications necessary.

Rather then installing a full fledged MTA you can install a minimal MTA.
A minimal MTA won't do any of the advanced mail delivery and queueing, it will simply forward all email messages from that host to a "mailhub" (also know as a "smart host" or "SMTP relay") that will do the actual mail delivery to the intended recipients.
msmtp, ssmtp and esmtp are some commonly used lightweight MTA's.

What will my server's MTA then really do if I want to use Google's SMTP?

Two, maybe three things:

  1. provide /var/lib/sendmail functionality to all applications running on your server
  2. Authenticate (if necessary) and forward all email messages to Google's SMTP
  3. Maybe provide a SMTP service on localhost port 25 for applications that do have native SMTP support. That allows you to configure those applications to use localhost port 25 as the outgoing mail server rather than the mailhub with the minor the administrative benefit don't need to configure the credentials required for the mailhub in those applications.

How can I then send emails from Linux's CLI?

The minimal email client is mail or mailx and many much more advanced terminal email clients exists, alpine, mutt and others.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.