Dead.letter email. Same domain name, different mail server - php

I have a server setup "myserver.com" and I'm trying to send emails from a PHP/Apache application on this server. The host name is set to "myserver.com" and I can send emails to anyone outside of the myserver.com domain.
We are using a separate server/service and the problem is when I try to send emails to anyone on the myserver.com domain they don't get the email.
This also happens when I try to send via command line, I get a:
dead.letter... Saved message in /home/username/dead.letter
It seems that the MX record is being ignored... how can I force it to respect the MX record?
Thanks.

how can I force it to respect the MX record?
By setting a proper hostname. If the server in question does not provide every single service for myserver.com, it needs to use a subdomain.

Related

Need to send mail from my server and also from a 3rd party provider

Is it possible to send mail from two valid sources?
To expand on this, I run an online shop web app, to separate concerns (and servers) I'm now using a 3rd party to handle mailboxes, (zoho.com) so as you can imagine, my mx records point to their provided names, and spf looks as follows: v=spf1 mx include:zoho.com ~all everything with zoho works smoothly.
Now, at the end of each day we need to notify each of our customers about their orders, plus other various automated mails during the day.
These mails come from the server, and are all sent using PHPMailer, but knowingly not using SMTP because I would very quickly fill zoho's queues and quotas for outgoing mail.
And more importantly, I cannot don't receive mail from my own domain sent from the server, but all other users seem to get the server produced mails just fine.
So the question is, what can I do to make my server a verified sender for my domain without removing zoho of course, some change in the SPF?
You can include multiple domain names, and your ~all should be -all
v=spf1 mx include:zoho.com include:myotherdomain.com -all
The actual problem here was the MTA settings with Exim, where my own domain name was set as a localdomain, hence the mail wasn't even leaving the server, by changing it to remotedomain mails started working normally.

Sending mail from webserver to external mail server with local domain name

This is an issue I've encountered several time and haven't yet found a decent solution for:
Sending an e-mail from a webserver on e.g. "domain.com", to info#domain.com which is hosted on an external mail server e.g. Google Mail
In my case I always send from PHP over Apache and often on shared hosting, but I can imagine this is the same case on other frameworks.
These e-mails always seem to be delivered to the local mail server, even if I set the MX records on that server to point to the right external mail server.
A solution for this is to use an external SMTP server, but this isn't always easy when you're working with clients that either need to set-up a new e-mail account on their server and provide the SMTP details or sign-up for a third-party SMTP server.
What is the solution for this? Is there no way around SMTP?
Most emai/MTA server "autoconfigure" themselves. They guess list of local email domains (doimans with locally hosted mailboxes).
In sendmail case you can turn it off adding the following line in sendmail.mc:
define(`confDONT_PROBE_INTERFACES', `True')
Documentation : cf/README - confDONT_PROBE_INTERFACES
I have had the same issue many many times (in my case using PHP on a LAMP stack).
Try/check the following.
If you are using cPanel or similar, set the MX records to the external mailserver (Google apps etc).
Set up an SPF record to allow your hosting website to send email (this way no need to configure SMTP).
This may not be applicable but if you are using something like phpmailer. Set the property $mail->isMail(); so it tries to use your SPF allowed local mail() function to send the email. Sorry for going off into very specific advice, but might help in your particular situation.
Worth checking there are not similarly named local mailboxes on your hosting box.
Hope this helps!

PHP mails going into spam from Amazon Ec2

I have an application hosted on amazon EC2. Now a user can send out invitations to join but on most email clients its showing up in the spam folder. Is there anyway to find out on what criteria it is actually being filtered.
First of all, please check to see if your domain/IP has landed on any blacklists:
https://www.mxtoolbox.com/blacklists.aspx
Second of all, have you set an SPF record? Explanation below:
http://www.openspf.org/Introduction
https://mxtoolbox.com/spf.aspx
This is a way to qualify a particular server/IP as being a valid for relaying/sending mail on behalf of a particular domain. Sendmail - or whatever PHP is configured to use to send mail - can actually send mail for any user on any domain (i.e. "spoofing"). However the server receiving the mail (e.g. a recipients POP3 server where received mail is stored and filtered) is probably going to check whether or not that server is supposed to be sending mail for that domain based on what's in the domain's DNS entries. In particular, it will probably check the SPF record, so you will need to set this. You should consult whichever service manages your DNS (i.e. your nameservers) for how to do this. You can look up where your nameservers are using the whois, dig or nslookup commands (or just use a web based whois service) - look for the "nameserver" entries, often denoted by "ns".
This is one of a number of factors that may be affecting whether or not your mail goes to spam. This subject is something of a "can of worms" and goes way beyond setting up your PHP mail function correctly. Rather than trying to reiterate all of these issues here, I'll direct you to this post on serverfault:
https://serverfault.com/questions/106598/all-my-emails-to-yahoo-hotmail-and-aol-are-going-to-spam-though-ive-implemen
Do you use 5th parameter in mail function?
mail('reciever#address.com', 'the subject', 'the message', null,
'-fyour#address.com');
It helps sometime.
Also maybe your IP was blocked before you start to use it.

PHP emails sent to exchange server are split between two addresses

I'll try to explain the problem we have at my company the best I can :
So I have several forms across different servers. All are sent up to send emails with the mail() function in PHP to the email address email#ourcompany.fr
Now I've noticed a weird behavior : when the forms are hosted on our server (I'm talking about our apache server, the mails are handled by an exchange server) they arrive fine at the address up there.
But when the forms are hosted anywhere else on the internet, the emails arrive at the address email#ourcompany.es
What could the problem be ? SMTP configuration ? A set of rules at the exchange server ?
I am pretty much a newbie when it comes to emails and how they're handled when they're sent...
Thank you for your help.
EDIT: As per MarcB recommendation I tried the following in the shell :
XXXX:~$ nslookup -type=mx securitasdirect.es
Server: 10.40.144.166
Address: 10.40.144.166#53
securitasdirect.es mail exchanger = 10 smtp.securitasdirect.es.
XXXX:~$ host -t mx securitasdirect.fr
securitasdirect.fr has no MX record
XXXX:~$ host -t mx securitasdirect.es
securitasdirect.es mail is handled by 10 smtp.securitasdirect.es.
Alright so based on your update... and running dig from my local machine to confirm, your securitasdirect.fr domain has no MX records setup on the publicly accessible DNS servers.
Internally in your network, it's possible (likely even) you use different DNS servers which have MX records and hence internally you can deliver email to #fr while externally it's not working.
Update not sure if you're changing things as I write this answer, but it seems like I'm now getting a valid MX return for securitasdirect.fr.
Beyond that, securitasdirect.fr fails the rDNS test (see: http://www.mxtoolbox.com) while securitasdirect.es passes. It's possible this is also interfering with mail delivery.

How to send email from a specific ip address?

I'm running a vps with cPanel/CentOS, And i want to dynamically choose the IP address to send an email from right inside the php code. ( i'm open to any weired ways )
Is there any way to do that? i would really appreciate some clear ideas as i'm not that good at exim and stuffs.
P.S. i already have available IPs in WHM.
Thank you
You can achieve this by using sendmail and passing parameters to define the configuration file to use. Inside the configuration file you can use the Masquerading And Relaying options together with CLIENT_OPTIONS(`Addr=aaa.bbb.ccc.ddd') to send via a certain IP.
When using PHP mail use the additional_parameters to specify the sendmail config file to use and in that config file use the above options to configure it.
PHP has no control whatsoever over the SMTP server that sends the mail. You can bind SMTP servers (sendmail, postfix, exim, etc...) to specific interfaces, but that's got nothing to do with PHP. PHP's involvement with the email sending process is purely to generate the mail and then hand it over to an SMTP server for actual delivery.
Here is a thought. If what you need is to send the mail from a specific IP you have control over, but where the impetus for that mail doesn't originate from that IP, but from some web interface or whatever, you could:
Add the mail details to a table on a DB with the desired IP address as a field.
Setup crons to run a php script on each box with those IPs.
Parse over the table with that script to find any mail that needs to come from that IP.
Send the mail.
I have a reseller account on a virtual host and all my domains for example are under the same IP number, then whatever domain I'm using to send an email, it will be sent under the same IP number, I think it is controlled by the smtp especification, you can configure your smtp to send email with another server where of course you have an account.
Also create a table to control what server you want to use to delivery yours email.
ClientPortOptions and DaemonPortOptions are special cases since multiple
clients/daemons can be defined. This can be done via
CLIENT_OPTIONS(`field1=value1,field2=value2,...')
DAEMON_OPTIONS(`field1=value1,field2=value2,...')
Note that multiple CLIENT_OPTIONS() commands (and therefore multiple
ClientPortOptions settings) are allowed in order to give settings for each
protocol family (e.g., one for Family=inet and one for Family=inet6). A
restriction placed on one family only affects outgoing connections on that
particular family.
Source: http://www.sendmail.com/sm/open_source/docs/configuration_readme/

Categories