Sending mail to gmail using sendmail

sendmail

I am facing issues while sending out mail to gmail accounts from my gmail account. After sending mail, i receive mail in my linux-box itself which says Authentication required.
When i saw the log i found

Sep 13 02:28:05 ip-172-31-25-143 sendmail[9264]: v8D2S5gQ009264: from=ubuntu@ip-172-31-25-143.ap-south-1.compute.internal, size=141, class=0, nrcpts=1, msgid=<201709130228.v8D2S5gQ009264@ip-172-31-25-143.ap-south-1.compute.internal>, relay=ubuntu@localhost
Sep 13 02:28:05 ip-172-31-25-143 sm-mta[9265]: v8D2S54l009265: from=<ubuntu@ip-172-31-25-143.ap-south-1.compute.internal>, size=487, class=0, nrcpts=1, msgid=<201709130228.v8D2S5gQ009264@ip-172-31-25-143.ap-south-1.compute.internal>, proto=ESMTP, daemon=MTA-v4, relay=localhost [127.0.0.1]
Sep 13 02:28:05 ip-172-31-25-143 sendmail[9264]: v8D2S5gQ009264: to=<kumargauravgupta3@gmail.com>, ctladdr=ubuntu@ip-172-31-25-143.ap-south-1.compute.internal (1000/1000), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=30141, relay=[127.0.0.1] [127.0.0.1], dsn=2.0.0, stat=Sent (v8D2S54l009265 Message accepted for delivery)
Sep 13 02:28:06 ip-172-31-25-143 sm-mta[9267]: STARTTLS=client, relay=gmail-smtp-msa.l.google.com., version=TLSv1.2, verify=FAIL, cipher=ECDHE-RSA-AES128-GCM-SHA256, bits=128/128
Sep 13 02:28:06 ip-172-31-25-143 sm-mta[9267]: v8D2S54l009265: to=<kumargauravgupta3@gmail.com>, ctladdr=<ubuntu@ip-172-31-25-143.ap-south-1.compute.internal> (1000/1000), delay=00:00:01, xdelay=00:00:01, mailer=relay, pri=120487, relay=gmail-smtp-msa.l.google.com. [74.125.200.109], dsn=5.0.0, stat=Service unavailable
Sep 13 02:28:06 ip-172-31-25-143 sm-mta[9267]: v8D2S54l009265: v8D2S64l009267: DSN: Service unavailable
Sep 13 02:28:07 ip-172-31-25-143 sm-mta[9267]: v8D2S64l009267: to=<ubuntu@ip-172-31-25-143.ap-south-1.compute.internal>, delay=00:00:01, xdelay=00:00:01, mailer=local, pri=30000, dsn=2.0.0, stat=Sent

I saw an answer that says that i have to change my hostname so that it resolves to exact IP of my device. I can do that, but I am afraid because of below issues i'm not sure of

  1. I have to do this on production server which hosts my webapp, so does changing hostname from /etc/hostname and /etc/hosts will cause issues in accessing my webapp using my domail name ie: pixyfi.com?
  2. Will there be any impact on accessing internet from this machine?

or if there is something else that i need to do, other than changing hostname then please let me know that

Best Answer

There are two different ways of sending mail:

  • as a mail client (like thunderbird or outlook)
  • as a mail server (like sendmail or postfix)

Although your are sending through sendmail mail server, googles considers the mail session between your sendmail server and google mail server as as mail client session, because your FROM address is a google mail address. So it requires authentication as your mail client would do it, to prevent anyone except you sending mail on your behalf via google mail servers.

All the other stuff doesn't apply in this case, because it only relates to situations, when your sendmail server tries to deliver mails with sender addresses of your domain pixyfi.com or clients of yours with their own domains.

All this sending mail on behalf of anyone was possible until about 20 years ago, when everyone had to start to protect his mail server against abuse.

Edit: Sorry forgot to answer your explicit question whilest trying to solve your problem.

  1. Yes, you have to care about the name of your sendmail server (in a way described below), the one that ultimately sends email to the world.

  2. No, the machine's internal hostname usually isn't even visible to the outside world. Except that some software may use it by default if you don't configure it adequately.

Don't worry about the hostname of your machine - the one which is set and read with the command hostname. Your web server can be configured to use any other name, and if you host more than one domain on the same server, it even must be configured to do so for each of your domains.

Same to the mail server; it may by default use your hostname to identify itself, but that's configurable, too.

Just make sure that:

  • the name sendmail uses to identify itself during HELO and
  • the reverse lookup of your IP address (nslookup 35.154.25.164)

are equal, because some mail servers require this in order to accept mail from your server.

More answers to what I called "all the other stuff" above can really become a huge article, so I won't continue here. I've seen a good generic answer on serverfault somewhere, but I can't find it just now. So I just point you to the information Google and AOL give to postmasters:

Related Topic