We are having a problem with a web application delivering emails. Suppose the site lives on domain.com. Emails sent to manager#domain.com aren't being recieved by the client, but when we set it to developer#developersdomain.com or manager#aliasdomain.com they are received by the developer and the manager, respectively.
Is php's mail() command delivering email addresses to the location domain to localhost, instead of routing it through a mail server?
Sadly, this is the way that the mailserver itself works. It knows the machine it's on is domain.com and assumes the mailbox should be a local box.
This is why it's a good idea to have your server's domain name actually be a subdomain, even if it's just www.domain.com. That way, mail addressed to manager#domain.com is sent on to the mail server specified by domain.com's MX record.
That'll be a setting on your mail software at the serverside I guess! Check your software settings.
Related
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!
I'm created a website with PHP on a Linux web hosting package. Normally I will get emails sent by its contact form that produced by PHP Mail() function. But this time, it is a strange case for me.
My customer company has a mail server. If I send an email via my personal email on Gmail, they will get it on their mail server. But when I send emails via contact form, emails go to webmail on website hosting package.
I've removed all email accounts on this host, also I removed DNS MX record from it, but still I can not receive emails sent by contact form on the company mail server accounts.
How can I solve this problem?
As it seems from your question the webshoting provider is also your email hosting provider. The way you explained the problem leads me to the conclusion that your PHP script uses the mail() function which will internally call the MTA (like sendmail) to send the email.
Now what seems to happen here is that PHP is sending the mail through mail() function which is passing it on to the local MTA (like sendmail) which is checking the local configuration. In the local config it seems to find the recipient domain as a local domain and deliver the mail locally to the user. In this case the email is not even leaving the webhoster's server.
As this is not what you expect, you have 2 possibilities if you do not have influence to the MTA's configuration (what i think you dont have).
I would propose (if possible) to not use the mail() function. There are ready to use SMTP classes which will connect to a SMTP server of your coice to send the email to. In that way you can avoid this problem. You should find something in the PHP Classes Repository.
Send the email to a different domain if possible. That way the MTA has to check DNS and send the email to another SMTP server for delivery.
The first thing to establish is how you are sending emails (sendmail or SMTP). Then, whether your emails are a) not sent at all or b) getting rejected by the destination mail server.
I'd check all available logs (source and destination mail servers and daemons). See if mail() itself is erroring. Try using sendmail/smtp directly.
If its the destination server rejecting the mail based on its spam score, try setting SPF records to enable the web server to send mail legally.
If your email function "mail($to,$subject,$message)" is not working then you need to check the server configuration. Now it is enable or not .
For more details, see here : https://wycks.wordpress.com/2013/10/09/when-phps-mail-function-doesnt-work/
I have a local server which host PHP applications. My applications send emails to different addresses. However, I am noticing a problem that I am unable to figure out. It send emails to internal addresses but it won't send messages to external addresses.
I also have an exchange server on the same network. so for example I have these 2 "internal domain"
domain1.com
domain2.com
if I execute this php function from my application it gets delivered with no problem
mail("name#domain1.com","Test Subject","Test message");
However, if I try sening a message to gmail, yahoo or any external domain it does not send it
mail("name#gmail.com","Test Subject","Test message");
My server is running on Windows 2008 Server R2 with PHP5.3.19 installed on it via IIS6
How Can I correct this issue?
mail() on Windows needs extra config in php.ini because Windows does not have Sendmail or anything similar.
The first is the SMTP setting which should point to your ISP's outbound server which is not necessarily the same server that you retrieve your mail from. When I worked in support there were a lot of issues like you describe because an inbound server will still accept mail, but only for the domains that are local to it.
The second is the sendmail_from setting, which is what the gimpy little mailer PHP wrote for the Windows distribution uses in every SMTP transaction regardless of what's in the headers. On *nix Sendmail will read the headers and get the From: address itself, on Windows PHP will always use what's in php.ini. If this is a "garbage" address like example#example.com or something with a non-existant domain many mail servers will reject it outright. What I recommend is to change it to something decent in PHP.ini as well as adding the following line to your mailing scripts:
ini_set('sendmail_from', $from_address);
Alternatively, just use PHPmailer since it simply works much better than PHP's horrid little mail() function.
On my client's website (domain.com) we have a contact form which sends an email to the client an me (client#domain.com and me#gmail.com).
The email is sent using PHP mail() function.
The website is hosted on my web server (MediaTemple DV) but the client has it's own server where Exchange is running (IP: xx.xxx.xx.xx, DOMAIN: server.com). Since the emails are handled by his server, I had to modify the DNS records on domain.com.
A: mail.domain.com -> xx.xxx.xx.xx
MX: (0) domain.com -> mail.domain.com
MX: (10) domain.com -> mail.server.com
When I use the contact form, I don't get any PHP error but only me#gmail.com receives the message.
After a few minutes, qmail (MediaTemple mail system) sends me an error email saying that client#domain.com "no longer accepts mail".
What's weird is that when I send an email to client#domain.com FROM gmail.com, then he gets it. Note that the client can still send email from Outlook with no problem.
Also note that all my other emails on other domains on my MediaTemple server work fine.
Does anyone have an idea why it behaves like this?
Thanks!
Make sure the mail service for the domain is turned off on the (dv) - it's trying to deliver locally and not even checking the DNS. That should immediately solve the problem.
(Also, probably a question for ServerFault?)
I'm developing a Web application with PHP 5.3.3.
I want it to send confirmation e-mails automatically.
I don't have a domain name yet.
I'm using Windows XP.
I don't have PEAR's Mail package.
I have hMailServer and is the mail server I want to use to send the e-mails.
My questions are:
Can I send e-mails without a domain name? (Is it absolutely necessary? I just want to test the application for the moment.)
If a domain name is necessary, do I also need to host the application with a Web Hosting Service Provider? Can I do it from my computer?(Remember, I just want to test the application.)
Do I absolutely need the PEAR's mail package? or can I simply use the mail() function?
I'm clueless about what I should do. I've made my research, I understand the parts but I can't make sense of the whole, I mean what resources are necessary and how to put it together. I've never developed any application that sends e-mail before. Please, help me.
Yes. You can set your "from" address to whatever you want. (Though note, the recipient server might detect it's forged and reject it.)
You can host from you computer, just make sure your network is not blocking port 25 outbound.
mail() alone will suffice as long as you have a local SMTP server that will handle your messages. (I'm assuming that's what the hMailServer product is.)
First off, if you're running Windows as your server, you need to configure how your e-mails will be sent (SMTP server). Go to this section in your php.ini file. Change localhost to an SMTP server you can use from your network (either the IP address of your hMailServer OR sometimes you need to purchase one to use like http://www.smtp2go.com/).
[mail function]
; For Win32 only.
; http://php.net/smtp
SMTP = localhost
; http://php.net/smtp-port
smtp_port = 25
Second, you use the mail(...) function in php (including the ability to send HTML mail). That's it.
Yes, you can. I believe your emails will show up with your server's DNS by default, but you can set the from: header to whatever you want. However, if you change the from: header, be warned that your emails are likely to get picked off by spam filters.
You need some special server configuration to use the php mail() function - I haven't tried setting it up myself, but I know that a basic local apache / php install won't have the capacity to send emails. Pretty much every paid web server should have it set up properly, though.
No. You can send regular and html emails with the generic mail() function.