Send authenticated mail through sendmail - email

I'm using sendmail to send a bunch of e-mails (I really have to send this e-mails, unfortunately) through php. The e-mail began to get into gmail and yahoo's SPAM boxes as soon as I stopped using my domain SMTP server, and started using the server's sendmail facility (I separated my domain name provider from my host, which is now Amazon).
After studying a little, I realized that I could solve this problem just by sending the e-mail authenticatedly (i.e. through my domain's SMTP server). Can I do that through configuration in sendmail? That way, I wouldn't need any changes on my application, only on my server infrastructure.
The headers I'm receiving (from an email at gmail)
Delivered-To: ***********#gmail.com
Received: by 10.227.152.2 with SMTP id e2cs188839wbw;
Fri, 29 Oct 2010 03:39:45 -0700 (PDT)
Received: by 10.100.13.16 with SMTP id 16mr263366anm.209.1288348783979;
Fri, 29 Oct 2010 03:39:43 -0700 (PDT)
Return-Path: <apache#ip-10-194-150-64.ec2.internal>
Received: from ip-10-194-150-64.ec2.internal (ec2-75-101-144-206.compute-1.amazonaws.com [75.101.144.206])
by mx.google.com with ESMTP id x32si2412082vcr.72.2010.10.29.03.39.43;
Fri, 29 Oct 2010 03:39:43 -0700 (PDT)
Received-SPF: neutral (google.com: 75.101.144.206 is neither permitted nor denied by best guess record for domain of apache#ip-10-194-150-64.ec2.internal) client-ip=75.101.144.206;
Authentication-Results: mx.google.com; spf=neutral (google.com: 75.101.144.206 is neither permitted nor denied by best guess record for domain of apache#ip-10-194-150-64.ec2.internal) smtp.mail=apache#ip-10-194-150-64.ec2.internal
Received: from ip-10-194-150-64.ec2.internal (localhost [127.0.0.1] (may be forged))
by ip-10-194-150-64.ec2.internal (8.13.8/8.13.8) with ESMTP id o9TAdhxQ017836
for <*************e#gmail.com>; Fri, 29 Oct 2010 06:39:43 -0400
Received: (from apache#localhost)
by ip-10-194-150-64.ec2.internal (8.13.8/8.13.8/Submit) id o9TAdhHk017833;
Fri, 29 Oct 2010 06:39:43 -0400
Date: Fri, 29 Oct 2010 06:39:43 -0400
Message-Id: <201010291039.o9TAdhHk017833#ip-10-194-150-64.ec2.internal>
To: ***********#gmail.com
Subject: Esqueci minha senha
From: Cidade dos Bicos <*****************#cidadedosbicos.com.br>
X-Mailer: Cidade dos Bicos
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
Thanks

no that's not the real issue here, it's all about headers, if you send the correct heeaders attached to the mail you won't end up getting into the spam box if you don't actually spam them ;)
edit:
here is a site going through what headers and how they should be set
http://www.transio.com/content/how-pass-spam-filters-php-mail

The following code has worked for me in the past. Give it a try and let me know.
$to = "someguy#gmail.com";
$subject ="Howdy Pardner?";
$message="I'm riding west, join me";
$headers = 'From: me#philar.com' . "\n" .
'Reply-To: me#philar.com' . "\n" .
'Content-Type: text/html; charset="utf-8"' . "\n" .
'X-Mailer: PHP/' . phpversion();
mail($to, $subject, $message,$headers);

For further referral: all my problems were because of bad configured DNS entries. Terms like MX, mx CNAME, PTR, DKIM should be in your veins when you decide to send e-mail.
This is a good reference: http://www.codinghorror.com/blog/2010/04/so-youd-like-to-send-some-email-through-code.html

Related

mail not sending to hotmail and gmail

i have a problem with sending email from my server to hotmail and gmail. seems the mail is just dropped, no returned bounce email notices etc. the emails just vanish. I have looked around for solutions on the net but nothing seems to help. below are the email headers of one mail which is send correctly to another big provider, without any problem. As i cant make any sense of it as to why hotmail is rejecting these mails, i hope someone can make something of it and give me directions on maybe a solution:
Return-Path: <s----#----.nl>
Delivered-To: <s----#ziggo.nl>
Received: from md2.tb.mail.iss.local ([212.54.34.152])
by mc7.tb.mail.iss.local (Dovecot) with LMTP id lQqGGXGJuFUZJAAAqQNqOQ
for <s----#ziggo.nl>; Wed, 29 Jul 2015 10:10:01 +0200
Received: from mx24.gn.mail.iss.as9143.net ([212.54.34.152])
by md2.tb.mail.iss.local (Dovecot) with LMTP id lPAPLTGvolV/XgAAH7GgQA
; Wed, 29 Jul 2015 10:12:41 +0200
Received: from mail.lastikweb.eu ([185.10.49.172])
by mx24.gn.mail.iss.as9143.net with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256)
(Exim 4.82)
(envelope-from <s----#----.nl>)
id 1ZKMR6-0001UG-T6
for sleenheer#ziggo.nl; Wed, 29 Jul 2015 10:10:00 +0200
Received: from localhost ([127.0.0.1] helo=aicit.nl)
by mail.lastikweb.eu with esmtpa (Exim 4.76)
(envelope-from <s----#----.nl>)
id 1ZKMR6-0001R8-EW
for s----#ziggo.nl; Wed, 29 Jul 2015 10:10:00 +0200
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8;
format=flowed
Content-Transfer-Encoding: 7bit
Date: Wed, 29 Jul 2015 10:10:00 +0200
From: s----#----.nl
To: s----#ziggo.nl
Subject: mail headers
Message-ID: <8670b9ca857e112fbc307d29ee84ccb2#aicit.nl>
X-Sender: s----#----.nl
User-Agent: Roundcube Webmail/0.9.5
X-Ziggo-spamsetting: Instelling=Gemiddeld Scorelimiet=14
X-Ziggo-spambar: /
X-Ziggo-spamscore: 0.0
X-Ziggo-spamreport: CMAE Analysis: v=2.1 cv=DeLq0aZW c=1 sm=0 tr=0 a=cWpRTkv7rqSFuHP3f9xSTw==:17 a=XVisR3dVAAAA:8 a=cIF5Tx0qAAAA:8 a=drCK43fGrOkA:10 a=IkcTkHD0fZMA:10 a=zOBTXjUuO1YA:10 a=nS36O97Bj3wUElCrIrAA:9 a=QEXdDO2ut3YA:10 xcat=Undefined/Undefined
none
X-Ziggo-Spam-Status: No
X-Spam-Status: No
X-Spam-Flag: No
test
I have dkim installed, tested all settings with mxtoolbox (dns, smtp etc) al seems to be right, but still Hotmail and Gmail is not accepting emails from my server (which holds about 25 domains, all sending through this server).
thanks!
Gmail ending up in spam is related to designated user not being able to send out through main server. case you have server: mail.server.com and you are sending mail with my.domain.com, the spf record needs to hold the ip6 of mail.server.com in spf. Obviously rDNS needs to be correct. For the hotmail problem, this is purely microsoft. you can check up with support from outlook.com, but only thing you get is "we dont block your server, although some emails are filtered. this can be caused by mitigation time, which can take up to 48 hours". Thats it. No messages are returned, simply dropped. Maybe msn.com outlook.com and live.com are experiencing the same problem.

Outgoing mail is ending up in spam

I have a problem with all the mails sent from my company, often ending up in the recipients spam folder. It's from approximately 5-6 different mail adresses sending from the same mail server. We have a dedicated server that is both hosting out website aswell as managing all mails and so forth.
We usually don't get any error messages when the mails either never arrives, or ends up in the recipients spam folder.
But we received this 1 error message, so i hope you have an idea of what to do to keep our mails out of the spam folders. We might have to hire external developers to take care of the problem, i just want to get an idea of what the problem is, so i know if i can fix it, or tell the developers what to do.
"ANON" is put in, to keep mails involved anonymous. Should i delete anything else?
Error message:
-----Oprindelig meddelelse-----
Fra: Mail Delivery Subsystem [mailto:mailer-daemon#googlemail.com]
Sendt: 27. september 2013 08:26
Til: support#example.com
Emne: Delivery Status Notification (Failure)
Delivery to the following recipient failed permanently:
ANON#ANON.dk
Technical details of permanent failure:
Message rejected by Google Groups. Please visit
http://mail.google.com/support/bin/answer.py?hl=en&answer=188131 to review our Bulk Email Senders Guidelines.
----- Original message -----
X-Received: by 10.14.109.66 with SMTP id r42mr7804640eeg.43.1380263171652;
Thu, 26 Sep 2013 23:26:11 -0700 (PDT)
Return-Path: <support#example.com>
Received: from server.example.com ([2a01:4f8:121:267::2])
by mx.google.com with ESMTPS id
o7si4443732eep.48.1969.12.31.16.00.00
(version=TLSv1 cipher=RC4-SHA bits=128/128);
Thu, 26 Sep 2013 23:26:11 -0700 (PDT)
Received-SPF: neutral (google.com: 2a01:4f8:121:267::2 is neither permitted nor denied by best guess record for domain of support#example.com) client-ip=2a01:4f8:121:267::2;
Authentication-Results: mx.google.com;
spf=neutral (google.com: 2a01:4f8:121:267::2 is neither permitted nor denied by best guess record for domain of support#example.com) smtp.mail=support#example.com;
dkim=neutral (bad format) header.i=#example.com
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=example.com; s=default;
h=Content-Type:MIME-Version:Message-ID:Date:Subject:In-Reply-To:References:T
o:From; bh=E5v2ubiy1T/bYA8pEndEZlZwb928MRpgJuoPSy8WsQE=;
b=AbAc/65Y88xmhdGHxUUs3kK/1rOvTH0uEpPAVEN1sv8KNdJvzvRqiO72gqXan0M7wXRVeev6IJ
0iumBwj875irmYAaST9hzm+eIF02whaZDgkzRr2jjJKN9bn11tBmtlTK0JzTGDUMf1Ij+qmI
0iumBwj875irmYAaST9hzm+eIF02whaZDgkzRr2jjJKN9bn11tBmtlTK0JzTGDUMf1Ij+vdF
0iumBwj875irmYAaST9hzm+eIF02whaZDgkzRr2jjJKN9bn11tBmtlTK0JzTGDUMf1Ij+f
64lUpYIyyaqlNUYnaPt28=;
Received: from post.ABCDEFGHIJK.com ([xxx.xxx.xxx.xxx]:49696
helo=WIN7UVQT1EBIRO)
by server.example.com with esmtpa (Exim 4.80.1)
(envelope-from <support#example.com>)
id 1VPRUi-0008Dh-Os
for ANON#ANON.dk; Fri, 27 Sep 2013 06:25:41 +0000
From: "ANON - example.com" <support#example.com>
To: "'XYZ ABC'" <a.bcd#efg.hi>
References: <E1VORD0-0007hu-Jn#server.example.com>
<CACyHzxudCSh+4NOEu-_QR1yQYA=uR0DOrTTcgDsg9KcRLTWDFQ#mail.gmail.com>
In-Reply-To:
<CACyHzxudCSh+4NOEu-_QR1yQYA=uR0DOrTTcgDsg9KcRLTWDFQ#mail.gmail.com>
Subject: SV: example.com: Ordre # 700003820 opdatering
Date: Fri, 27 Sep 2013 08:25:38 +0200
Message-ID: <00d501cebb4a$637159b0$2a540d10$#example.com>
MIME-Version: 1.0
Content-Type: multipart/related;
boundary="----=_NextPart_000_00D6_01CEBB5B.26FF0BB0"
X-Mailer: Microsoft Outlook 14.0
Thread-Index: AQGYr839QgwXgZ5pAdux+XF0Yh5W4AHfGYRhmjY70GA=
Content-Language: da
X-AntiAbuse: This header was added to track abuse, please include it with any abuse report
X-AntiAbuse: Primary Hostname - server.example.com
X-AntiAbuse: Original Domain - ANON.dk
X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12]
X-AntiAbuse: Sender Address Domain - example.com
X-Get-Message-Sender-Via: server.example.com: authenticated_id:
support#example.com
X-Source:
X-Source-Args:
X-Source-Dir:
I needed to edit the MX records for the domains sending the mails, as the domains and websites were on the same server the mail server couldn't comprehend it.

how to trace gmail sender from header?

Everyone knows changing mail address in address bar and pretending to send mail from someone else's accout is easy..
so i looked up on google "find out where email came from"
some of the links suggest-- 1. Log into your account and open the email in question.
Click on the down arrow that’s to the right of the Reply link. Choose Show Original from the list.
Now here’s the technical part that I was telling you about earlier! You need to look for the lines of text that start with “Received: from“.
I did all above steps but found out that gmail uses mail client ip as sender ip and not the ip of that particular PC(For security purpose they say...) It has sender's IP as mr. google.com and some private netwk IP(10.43.103.195)
so now my problem is -- is there any damn way in the world to trace where the hell did this mail come from??!!(at least IP of sender)?
This is the header i got when i followed above 3 steps which is of no use...--
Delivered-To: xxxxxxxx#gmail.com
Received: by 10.204.40.79 with SMTP id j15csp110512bke;
Fri, 22 Mar 2013 01:55:20 -0700 (PDT)
Return-Path: <xxxxxxxxxxx#gmail.com>
Received-SPF: pass (google.com: domain of xxxxxxxxxxx#gmail.com designates 10.43.103.195 as permitted sender) client-ip=10.43.103.195
Authentication-Results: mr.google.com;
spf=pass (google.com: domain of xxxxxxxxxxxx#gmail.com designates 10.43.103.195 as permitted sender) smtp.mail=xxxxxxxxxxxx#gmail.com;
dkim=pass header.i=#gmail.com
X-Received: from mr.google.com ([10.43.103.195])
by 10.43.103.195 with SMTP id dj3mr548753icc.3.1363942518977 (num_hops = 1);
Fri, 22 Mar 2013 01:55:18 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20120113;
h=x-received:mime-version:from:date:message-id:subject:to
:content-type;
bh=Vi/MI39WKoec07maKoVjz5/ZzUxhO1k+BoeRUkBbWOc=;
b=kZ/EniFvV15mZ9iBeKNiKsJsQvWHL5N8zqrazVxeKmAARQLotyAAIDU7Or9Xc1OBwY
cwuPqSKmVX1RV7tX5wwcdYyzEA/gmskzgGteimv0BInTzVO7dwgi4gU5cZYdm6Qj/GMo
rJfGs5ty6VjidYMFwyn0K5Z0frh2NX2e7RXP0R6da6U5WMU2bQ9epOD4ZhKF+bSdUvb9
WGu3/HWJNTgwrFivspsA6q0M6JkQWYFM6J83h62kIgU897gsXkRlwPacn63tHySC6CNm
DJZGzRJryQZEJTI4owOImP6XDrK+uxPDFAiTnIG5xFR8PBXsQp+FP+XcsqIHqXSjCtl1
xXdQ==
X-Received: by 10.43.103.195 with SMTP id dj3mr548753icc.3.1363942518971; Fri,
22 Mar 2013 01:55:18 -0700 (PDT)
MIME-Version: 1.0
Received: by 10.64.134.164 with HTTP; Fri, 22 Mar 2013 01:54:58 -0700 (PDT)
From: xxxxxxxxxxxx#gmail.com
Date: Fri, 22 Mar 2013 14:24:58 +0530
Message-ID: <CACD4ahHmkbNCj9G5taUkXYC=K=n4qVvxY75SSSv3hUG00r6dkQ#mail.gmail.com>
Subject:
To: xxxxxxxx#gmail.com
Content-Type: multipart/alternative; boundary=bcaec5171a235666e504d87f9dd8
--bcaec5171a235666e504d87f9dd8
Content-Type: text/plain; charset=ISO-8859-1
If the sender uses gmail/yahoo/hotmail etc. to send an email (ie. if they don't use a third-party software like Outlook or Thunderbird), there is no way to find out the "PC IP address" because it's hidden for 'privacy reasons.' Probably the only legitimate way (other than through legal means) is to ask the sender to reveal their IP address (using such tools like https://verifyyourip.com).

Email thrown to spam - what's wrong?

I tried many ways, to solve the problem, that mails are throw to spam in gmail... I set the Received: from, before it shown in gmail the note "noreply#odsantu.sk via lvps83-169-17-110.dedicated.hosteurope.de"... Now I have no idea, what can be wrong...
Delivered-To: dobikos#gmail.com
Received: by 10.14.125.5 with SMTP id y5csp282730eeh;
Thu, 22 Nov 2012 16:08:08 -0800 (PST)
Received: by 10.14.0.198 with SMTP id 46mr6776443eeb.21.1353629288333;
Thu, 22 Nov 2012 16:08:08 -0800 (PST)
Return-Path: <anonymous#vipfp.eu>
Received: from vipfp.eu (lvps83-169-17-110.dedicated.hosteurope.de. [83.169.17.110])
by mx.google.com with ESMTPS id a9si9044494eeo.114.2012.11.22.16.08.08
(version=TLSv1/SSLv3 cipher=OTHER);
Thu, 22 Nov 2012 16:08:08 -0800 (PST)
Received-SPF: neutral (google.com: 83.169.17.110 is neither permitted nor denied by best guess record for domain of anonymous#vipfp.eu) client-ip=83.169.17.110;
Authentication-Results: mx.google.com; spf=neutral (google.com: 83.169.17.110 is neither permitted nor denied by best guess record for domain of anonymous#vipfp.eu) smtp.mail=anonymous#vipfp.eu
Received: (qmail 13333 invoked by uid 33); 23 Nov 2012 01:08:07 +0100
To: dobikos#gmail.com
Subject: =?UTF-8?B?UG90dnJkZW5pZSBvYmplZG7DoXZreSBsaXN0dSBvZCBTYW4=?= =?UTF-8?B?dHU=?=
X-PHP-Originating-Script: 0:SendmailMailer.php
MIME-Version: 1.0
X-Mailer: Nette Framework
Date: Fri, 23 Nov 2012 01:08:07 +0100
From: "OdSantu.sk" <noreply#odsantu.sk>
Message-ID: <hyzaah4290#odsantu.sk>
Content-Type: multipart/alternative;
boundary="--------6p2unvd5n4"
----------6p2unvd5n4
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
.
.
.
contents
.
.
.
----------6p2unvd5n4
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit
.
.
.
contents
.
.
.
----------6p2unvd5n4--
Thanks
Staying out of spam filters is a bit like search engine optimization: it's a moving target.
But some basics:
send from a known hostname not some random IP
include user details (eg username, firstname, etc) in the content
make sure the From and Reply-to match
include actual text (empty or image emails often show as spam)
don't include links that look like spoofs
There are sites out there that track the latest trends you should be able to find them on Google.
Received: from vipfp.eu (lvps83-169-17-110.dedicated.hosteurope.de.
your system has a generic rDNS pointer which does not match the HELO, this can trigger spam filters. set your PTR to vipfp.eu as well in your vps control panel (or tell your vps hoster to do it for you if there is no reverse dns option in the control panel)
Received-SPF: neutral
consider adding SPF

Mail server altering reply-to address?

We have an application sending mail with reply-to addresses in the form of NNN#email.example.com. The mail is sent via Sendgrid and replies are parsed using Sendgrid's Parse API. The problem is some email doesn't get back to us because the reply-to address has been changed to NNN#sendgrid.net. Sendgrid support says they never touch the reply-to and we've confirmed by a Gmail logging account that our application sends mail out correctly. So that leaves me suspecting certain mail servers are switching the domain name with that of the MX host. Our MX records for email.example.com are:
mx3.sendgrid.net 20
mx4.sendgrid.net 20
mx5.sendgrid.net 20
mx.sendgrid.net 10
mx2.sendgrid.net 20
Are there any mail servers or clients that are known to modify reply-to addresses? Or is there any other possible explanation?
Edit Headers from an email send by our app and logged with a Gmail account (sanitized to remove client information):
Delivered-To: logger#company.com
Received: by 10.112.62.41 with SMTP id v9csp143404lbr;
Tue, 31 Jul 2012 04:25:29 -0700 (PDT)
Received: by 10.182.51.37 with SMTP id h5mr22717342obo.35.1343733928944;
Tue, 31 Jul 2012 04:25:28 -0700 (PDT)
Return-Path: <Editors#domain.com>
Received: from o1.email.domain.com (o1.email.domain.com. [208.117.48.105])
by mx.google.com with SMTP id m6si10752851oec.6.2012.07.31.04.25.27;
Tue, 31 Jul 2012 04:25:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of Editors#domain.com designates 208.117.48.105 as permitted sender) client-ip=208.117.48.105;
Authentication-Results: mx.google.com; spf=pass (google.com: domain of Editors#domain.com designates 208.117.48.105 as permitted sender) smtp.mail=Editors#domain.com; dkim=pass header.i=#Domain.com
DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=Domain.com; h=date
:from:reply-to:to:message-id:subject:mime-version:content-type
:content-transfer-encoding; s=smtpapi; bh=+VZlU9LWGUpMR4neAk/JMo
1DD2E=; b=T3Be3k1Gp+shIGgQZPJ1vtx1kUCRMCRAqRgf8LxVUdvQ1/7YWRKnls
+zrXi6dhJXaLrEyVmt7MyYgxvkVvnJqWYy4tAQABtANQHdLSle4AK1+BY+/m2h4E
fj91rMgQySNbrVV+mhaiE5Q7NxvIa35azUUO0/zRYpluDUt6UBEcQ=
Received: by 10.16.69.117 with SMTP id mf20.27729.5017C0A66
Tue, 31 Jul 2012 06:25:26 -0500 (CDT)
Received: from email.domain.com (unknown [10.60.208.17])
by mi15 (SG) with ESMTP id 5017c0a6.202a.a5e396
Tue, 31 Jul 2012 06:25:26 -0500 (CST)
Date: Tue, 31 Jul 2012 07:25:25 -0400
From: Editors <Editors#domain.com>
Reply-To: 5005#email.domain.com,
Editors <Editors#domain.com>
To: user#example.com
Message-ID: <5017c0a5d4365_e294729d8c86360#app02.manuscripts.domain.com.mail>
Subject: Invitation
Mime-Version: 1.0
Content-Type: text/html;
charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Sendgrid-EID: lcSu+eeYyj7byVT4rUR8IwFlWv7xwmQ9mjigbpHftFWQeg+HlxpNd7F1nbL2uoqLRAg4sHwj57Rrx78FZhDo2L2DCVfamQm0+wEFzkMnensGOv19JFRIAeDMZY53SVpKMwm4Klqcm6L6s9+UaFtqnRUE3/jexZ6uJAFc5x57JG4=
So you see the reply-to is set properly in these headers, but when the recipient replied we saw the reply-to address change to 5005#sendgrid.net.
We have the exact same issue. I'm no Exhange guru so I can't validate this - but I'm willing to bet the company you are sending mail to has a configuration flag that states to NOT use a 'reply to' command. Our application sends out as ourcompany#appmail.com with the reply to address set to user#mycompany.com. I can test with gmail and yahoo and it works great!
But certain companies we email always come back t the 'ourcompany#appmail.com' address as if there was no reply to set. Think about all the junk mail you get where the reply address is your own email address. I can only imagine MS and Novell have flags to force replies to the actual sender.
Now if we could just get clarification from a real expert as to whether or not this flag is out there.