I picked this script because it had a CAPTCHA and file upload/attachment. http://www.html-form-guide.com/contact-form/php-contact-form-tutorial.html/comment-page-2#comments
I know it is older, and the script writer isn't support it on their website.
The form is at HostGator at web address (fake of course, just using it for example) "abcinc.com". The company/website owner has their emails on an Exchange Server 2013 and is using "abc.com" for their mail.
The email the form creates - I receive it at my Google/Gmail accounts. I've used this script on this server for half dozen other people (different website organizations) who receive them fine (either using the Google/Gmail, Hostgator mail).
This client can not receive these emails on their Exchange Server (2013) at "abc.com" (and yes, I have the email addresses in the form correctly).
I'm just trying to learn something. That is why I'm here. I'm not a php programmer, I'm not a cPanel, Exchange Server or any kind of mail / server demi-god. All I know is I picked a script and modified it, hosted it at HostGator, and believed that when the form was used that HostGator sent the mail to whom evers email addresses are in the form.
The Exchange tech support people wrote me this:
I need to know the SMTP service you are using to send the email and if
it is possible for you to use a real email address from ABC.com to
send the email from the form.
Please take a look at the article below and try to mirror the settings
as best you can. Also, please us an actual email address from
abcinc.com to send the email if possible. I can create a new one for
you or you can use an existing one if you like. After you have made
these changes or if you have any questions, please reach out to me so
we can do final testing.
Here is a KB that has all the settings typically used for web
applications and other devices to be able to send using our servers.
If there web application is doing the sending portion, please see if
there are any logs available that may show
How To Configure Your Printer, Scanner, Copier, Web Script Or SMTP Application To Work With An Exchange Account
http://hosting.intermedia.net/support/kb/viewKBArticle.asp?id=2167
Here are the specific settings for your account. Note: this is an
Exchange 2013 server.
(I didn't include the settings here)
So after attempting to read through that my brain exploded. When I recovered I logged on with HostGator support to ask them... hell I don't know what I was trying to ask them.
They told me to give them my cPanel IP.
I then asked the Exchange Server people if they could just give me a script they knew worked. Yeah... I did. :-\
So my question is - what is keeping this Exchange Server from receiving these emails?
Mostly so I can become ever so slightly more educated than I was 10 minutes ago.
~Kaye
PS / EDITED
I came back to add, I just tried another (basic) form and they received it.
From the form that was not getting to the Exchange Server, this is the header info:
To: jill#abc.com
Subject: Contact form submission from Kaye
X-PHP-Script: www.abcinc.com/estimates.php for 76.3.118.189
Date: Fri, 13 Sep 2013 15:37:30 -0500
From: Kaye <nobody#www.abc.com>
Reply-To: kaye#mydomain.com
Message-ID: <be82ada010a752b86440e86e5c24ca0a#www.abcinc.com>
X-Priority: 3
X-Mailer: PHPMailer (phpmailer.sourceforge.net) [version 2.0.4]
MIME-Version: 1.0
Content-Type: multipart/alternative;
In the form that did work, it is using the actual email that the user enters into the form as the FROM email address - not the server. Is this what could be the issue the Exchange Server is having?
function GetFromAddress()
{
if(!empty($this->from_address))
{
return $this->from_address;
}
$host = $_SERVER['SERVER_NAME'];
$from ="nobody#$host";
return $from;
}
Most hosted Exchange providers include filters that will check for SPF records—or MX records at a minimum—for the domain with which the sender address is associated. Since there is most likely neither an SPF nor a MX record for www.[your-domain].com (because of the "www."), the hosted Exchange provider's SPAM blocker is marking the message as SPAM because it cannot verify that the IP address from which the message is coming is actually, legitimately associated with www.[your-domain].com—or, alternately (and perhaps more likely), that www.[your-domain].com has no MX or SPF records associated with it and thus the server assumes the message must be junk (because why would a domain name not configured for email be sending email?). [your-domain].com might have those records, but that doesn't necessarily cover the "www." subdomain.
I've dealt with this in my own personal experience before and found that Google Apps would process messages that various hosted Exchange providers would not. Some hosted Exchange providers do not even let you see what has been blocked (e.g. GoDaddy) and thus it makes it very difficult to troubleshoot.
Now, in your edited post, you mentioned that the script is now sending "from" the user-inputed address and that this has helped. You are correct to assume this has helped. Even though the sending IP address won't match the sender domain name, the receiving server likely has a policy to accept messages absent a specific reason not to (e.g. a blacklist entry or a complete lack of MX/SPF records for the domain name), even if the IP doesn't match the domain name.
These headers…
From: Kaye <nobody#www.abc.com>
Reply-To: kaye#mydomain.com
…are defective since the receiving server is mainly concerned with the "from" address. The reply-to address, although it may be valid, adds no credibility to a message and the mail server will not take the time to look at it if the "from" address is invalid or blacklisted.
This header…
Message-ID: <be82ada010a752b86440e86e5c24ca0a#www.abcinc.com>
…won't make a difference either way, despite the "www." in it. A Message-ID just needs to be unique and nothing else matters.
Related
I am in the process of having a web app built. And it will link into other people's websites.
It's purpose is to be a login to a portal which will manage their customers and data.
My app will at some point send an email to their customers acting upon the clients interest.
My concern is that we won't be hosting our clients emails.
So my question is can I get my web server web app to email the customers of my clients using their email domain name?
I think all I would need is the mail server and email account details.
I think I'll be using phpemailer unless anyone can recommend anything else? Is it even possible?
I'm just looking for answers or documentation ton help me setup configure if anyone knows of any.
Thanks in advance
As Barmar says, if your clients include your servers address in their spf records (and only use SPF for protection) then your mail server can send messages with a from address with the clients domain.
However, there another schemes, DKIM, which requires a private key issued by the client. To confuse things further, there is a scheme combining DKIM and SPF called DMARC.
Multiplexing the schemes and client keys via your own MTA is a formidably complex task. While #Barmar usually gives good advice, in this case I think a recommendation to simply ask the clients to include your domain in their SPF is not the best approach.
There are a lot of different choices:
a link back to the clients MTA (for clients whom operate their own MX) which would need to support SMTPS and SMTP authentication. Possibly even vpn support
the spf based model (for those not using DMARC or DKIM)
sending emails from your MTA but with a a masqueraded text part in the email address, e.g.
From: "a_user#yourclient.com" <a_user_yourclient#yourdomain.com>
...but with a Reply-to header pointing to the clients address, although this may impact your IPR
just use the clients email as the from address for those without any protection scheme
It would be straightforward to handle the initial routing of the email within your applications code, but you are going to need developers who really understand how email works in practice.
I would recommend you to use mailgun... Mailgun is simple to implement, you can send 10000 emails for free every month (see below) and you can send emails in behalf of clients domains. You need to add new domains to mailgun account and verify them like it's described in the documentation (see below).
Official SDK for php
https://github.com/mailgun/mailgun-php
Domain verification documentation https://documentation.mailgun.com/en/latest/quickstart-sending.html#verify-your-domain
Pricing plan if you need to send more than 10k per month..
https://www.mailgun.com/pricing
Here are some options:
If your client provides you with an account in their email environment, then you can send using those credentials. Assuming your client has a properly configured mail environment (SPF and/or DKIM and/or DMARC), then everything should be good.
You can send from your email server directly, but your client's SPF records should include your server's IP address(es) if you don't want the email to go to spam. (Though it's possible the email will not go to spam depending on a lot of voodoo related to spam filtering and IP reputation)
You could have your client setup a DKIM DNS entry with a public key that you generate. Then you could have your server sign the message using DKIM and send it on behalf of the client.
I have a PHP mail() script that sends a HTML email that contains embedded images.
The code is basically this:
mail($to, $subject, $message, $headers);
The headers are like so:
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="--a9cf4407bac7d49ebd2d94af284cb0d8"
From: Myname <name#domain.co.uk>
Reply-To: name#domain.co.uk
The email delivers fine to all outlook.com and gmail.com addresses. I've tested however when sent to our office which runs Microsoft Exchange 2003 the email doesn't deliver. It doesn't even reach the logs which baffles me. Exchange isn't blocking the email, it isn't even receiving it.
Is there a known PHP / Exchange 2003 conflict? Or is the issue elsewhere?
I'm happy to supply more code if needed.
You seem to be using php's native mail function. It is often cumbersome to configure and troubleshoot.
You may save yourself a lot of time by looking into PHPMailer or Swift Mailer. These libraries are constantly maintained and fixed to stay compatible with exchange and other systems.
Also, with exchange it may be easier for you to set up an email account on it and let your application use it.
I had the same symptoms a few years back and if your problem is the same as mine you'll be surprised to find out it has nothing to do with your code.
In my case I was sending mail from from an internally hosted web server to an also internally hosted mail server. The web server was in the DMZ interface(a firewall/networking term) and the mail server was on the internal interface. Each interface operates on a different IP subnet (again networking stuff). The DNS for the mail domain (mail.ourdomain.com) resolved to the external IP of our firewall--which is configured to route that traffic to the internal mail server. However, that configuration only worked for traffic coming from the outside interface (external traffic). Traffic originating from the DMZ interface (mail sent from our webserver) could not be routed to the internal mail server.
You can do a quick check to see if you have the same problem. SSH to your web server and attempt to ping the mail server using the dns name.
ping mail.domain.co.uk
If you get a response, then this may not be the same problem.
Otherwise check with whoever is in charge of the firewall / network security and work with them to figure out what you need to do to get traffic from the webserver to the mail server. In our case we added a hosts file entry for mail.domain.com resolving to the internal IP of the mail server instead of the external IP.
This has been a massive headache. We use Ning as a our platform for an arts event project. We want to ask our audience to upload photos to our website via an email address. The only issue is that Ning only will give us ridiculous email addresses for this purpose... such as photos34628234896#ourwebsite.com That hardly sticks in the mind!
So I thought, lets just forward emails from an easy to remember email address to the Ning's crazy one... BUT Ning doesn't allow any emails to upload photos if they are detected as being forwarded or redirected. I guess that detection is done through the email header.
So that is why I need a way to redirect an email to another address without that being reflected in the header info in the email. I thought perhaps Outlook receiving the emails from the easy to remember email address, then somehow resending them with a fresh clean header may be the answer? I can code in PHP, and run a home headerless ubuntu server on a domestic internet connection too if that may provide a better answer?
Any thoughts how I could achieve this goal?
If you can forward the email to your server you can have it piped to PHP which can then resend the email for you with whatever email address you wish to be displayed. Just make sure you have things like DomainKeys and SPF records set up for that server or else your chances of the mail being seen as spam will increase.
If you are using an Exchange server, you can use Transport rules to redirect the message, which will pass most forwarding checks. If it does indeed change the headers or something else, you can use the same ruleset to remove or modify them. Most MTAs(Mail Transport) will allow the same sort of functions, but it really depends on which one you use. Postfix is quite flexible.
The changes will be made in
Exchange Management Console
Origanization Configuration
Hub Transport
Transport Rules
Also, and maybe easier, you could simply try to add a secondary delivery address, in the mail flow settings for the fictional user you assign to receive the emails. This would be done in the user properties. Server level forwarding amy not trigger the forwarding blocks that you are encountering, as client forwarding does not work the in entirely the same way. Many clients send the email again, but the server redirects it.
Exchange Management Console
Recipient Configuration
Mailbox
Properties, Mail Flow Settings.
You would enable forwarding in Delivery Options.
Sorry, just noticed that you are using ubuntu, you can simply have postfix redirect the email for you, you will use Postfix Virtual Alias Maps...
Here is a link that describes it perfectly...
http://www.cyberciti.biz/faq/linux-unix-bsd-postfix-forward-email-to-another-account/
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 working on a website that allows you to send emails without registering, and without specifying a sender. You enter the recipient's address, subject, body and send. My problem is sending the message. What I'm trying to achieve:
User clicked send -> Subject,recipient,body sent to PHP -> Server validates the information -> Server creates a random email account -> Server sends the email through the random account created -> Server deletes the account
I'm stuck at the random email account creation step. How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
I googl'd the hell out of this issue and I can't find an answer.
Thanks!
BTW
I'm using Apache to "host" on my own Ubuntu
How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
The way to create E-Mail accounts varies wildly from server software to server software, and is usually not possible from within PHP.
Depending on your server's configuration, though, that might not be necessary: If you set up a catch all address for a domain, many server configurations will allow you to send out mails from any E-Mail on that domain (e.g. 123456789#example.com). Any responses will then go to that catch-all mailbox, the contents of which you will probably want to discard.
You have to realize, though, that this is exactly how spam providers operate. Extreme caution is advised if you don't want to end up on all sorts of spam blacklists.
I don't believe you can create accounts or email accounts on a server, using PHP, as this supersedes PHP's permission level. Sending emails this way is a good way to get your server banned, FYI. Also, if you insist on sending emails like this, why not just specify a dummy From: email address? It would essentially be the same thing as creating a dummy account anyhow.
You may also want to use the -f switch, for PHP's mail(). See php.net/manual/en/function.mail.php