Link to home
Start Free TrialLog in
Avatar of IP4IT Staff
IP4IT StaffFlag for Ireland

asked on

Contact form on website sends fine to Gmail address but not to our domain email when configured

Hi,

We have a contact form on our website that we are testing.

The form was created using HTML and I used PHP code to send the details through email.

I have it set that a person fills out the contact form, clicks on "submit" button and the details are sent as email to our Gmail address.

As emails kept going to spam, I set that contact form emails are sent from our domain email address to fix this.

These contact form emails sent successfully to our Gmail address but when sent to our domain email address, the email is not received and not in Junk folder (this email address receives and sends emails fine).

We would like to have contact form details sent to our domain email address.

What do we need to do to get this to work?

Thanks,
Robbie
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

There is most likely nothing wrong with your code. If it worked sending to GMail then the code is correct.

This could be a case of your sending / receiving server rejecting the email.

How are you sending the email?

Are you using PHP mail - or a library like PHPMailer?

If the latter are you using SMTP mail or using the servers default SMTP service to send?
Avatar of IP4IT Staff

ASKER

Hi Julian,

It is possible it could be server related for the contact form emails coming in to our domain email.

The email is sent through PHP mail.

Is there a setting or something we can check to see why the email may be rejected?

Thanks,
Robbie
No, if it is being rejected it is most likely after it has left your server.

This not a code issue.

What I recommend you do is rather use PHPMailer and use the SMTP option i.e. you authenticate to an SMTP server in your domain with a username and password that has access to that server (setup a dedicated email account for it with its own password)

Test to see if that gives better results.

Also consider using a service like MailGun - they configure their servers to ensure that emails are sent correctly - they have an API and you can use them as an SMTP server (with PHPMailer for example)
you can use this mail relay server : http://emailrelay.sourceforge.net/
you install it on your network, it receive the emails you want to send and send them using an authenticated email account
this also allow you to see the "traffic", what is sent/receive rejected and why. a GUI console is available and/or logs files
I've seen this issue before where the cPanel hosting account was configured to look at its own DNS zone records rather than the ones indicated by the name servers. ie the name servers for the domain were pointing elsewhere. For the MX zone record, this meant the mail for the domain was being sent to the wrong server, whereas mail for other domains (such as gmail) was unaffected.

Sometimes this is an option that gets chosen during creation of the hosting account.

A quick fix might be to add MX zone records to the cPanel hosting account pointing to the correct MX server, however if you're using DKIM that may not be enough. A better solution would be to configure the hosting account to look at the name servers to determine where to send the email (I'm not sure how to do this though, from memory). The solutions provided by the other experts should work, but may take more effort.

Another possibility could be that the hosting account (or the server it uses to send email) is not configured in the SPF zone record for the domain, which means it's unauthorised to send email for the domain. Each receiving mail server (eg gmail) determines how to handle such email, which means it might work for one recipient and not another.
Avatar of bleach77
bleach77

Is the "from" email address is the same as the "to" email address? If it is, try using different address.
Also, it's worth mentioning the "from" email address should be an address that does exist (even if email to it is ignored), to help avoid it being treated as spam.
ASKER CERTIFIED SOLUTION
Avatar of Julian Hansen
Julian Hansen
Flag of South Africa image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial