Email sent from form is not delivered to recipient - php

I made a php form but I have a problem. The form is sending the message and a thank message displays but am not receiving the message in my gmail inbox.

Check your server mail log. Check your Gmail junk folder.

Well post the code! I've used PHP's mail function and it worked. Perhaps Gmail is filtering the e-mail sent by PHP. Try using an e-mail account on a different domain to narrow down where the problem is.

Gmail may be treating the e-mail as spam. Try sending to an e-mail account not on Gmail.

This could be one of hundreds of problems, many of which are beyond your control.
I had a similar problem trying to make a simple PHP app to send email - one day it worked, the next day it didn't. No error. No indication that it failed. Nothing.
To debug the problem I installed Ubuntu on a virtual machine which meant I had my own web abd mail servers to play with - made it easy to check server side logs and multiple recipients etc. Basically you are in 100% control - if it works in this environment but not in the real world, chances are it isn't your fault!
Turned out that my web host had put in new security policies that the "From:" address had to be a physical mailbox on their system. Not my hosting user name. Not a forwarded web address.
- they just didn't bother to tell anyone they had done it!

Make sure your to and from set correctly. If the from is not an address gmail likes then it could be taken as spam.

Related

sending an email with codeigniter doesn't work when they contain a link

I have a script set up that will email a user an activation link when they insert their email into the provided input.
I'm using CodeIgniter's email class to send the multipart emails and the problem I'm having is that when the email is sent, the debugger says that the email was sent sucessfully but the message is never received.
When I send the email to my internal work email, it sends just fine. But when I send it to my gmail account, it never comes through.
I've managed to track down the issue as being a problem with inserting links within the email. When I remove the link, the email sends fine. I put the link back in and the email is never received by my gmail account.
Has anyone ever come accross this problem or do you have any insight into how to fix this?
your email is being rejected.. this is no CI issue..
Ok, so it sounds like the problem isn't with CodeIgniter or your code, but with the server's mail transfer agent sending it on to the Gmail server.
What happens is CodeIgniter puts together an email and gives it to the PHP engine, which passes it on to the mail transfer agent on the server for sending. The MTA will report back to PHP, and therefore CodeIgniter, that it has received the email properly. As PHP & CodeIgniter's jobs are finished at this point, they will report that they've sent successfully.
Check your spam folder in your Gmail to see if it's been put in there..? I haven't used CI for a while so can't remember exactly, but I think there's an HTML-email parameter you may need to set before you send. If so, Gmail might be expecting this to be set too.
Scroll down to 'Email Preferences' here:
http://codeigniter.com/user_guide/libraries/email.html and set the mailtype to HTML.
If that doesn't work, you will need to debug fully.
To debug the problem properly you will need to be able to access the MTA logs. Is this a local development server or a live production machine? Is it Linux or Windows? If Linux, which distribution? Do you know which MTA you are using? Do you have SSH access to the server?
If you can get SSH access and find out which MTA you have things will be a lot simpler to find out and you'll be able to monitor the outgoing messages and the destination servers' responses as they happen.

When setting up PHP mailer who should I set the From address as to avoid spam/blacklisting?

I'm using PHP mailer to as part of an enquiry form that I'm building for a client. One thing I've noticed in testing is that when I use my yahoo account as the FROM and my gmail as the to it works fine for a while but then it starts rejecting, I'm assuming because gmail is smart enough to know that the email isn't actually coming from Yahoo.
What is the best solution to this? I could use the email from the person who has actually filled in the form to show as the FROM address but I'm worried that this may eventually cause the same problem anyway? I could also send it from an email on the domain that its sending from but will that stop it from appearing as spam or black listing that email?
Any help or guidance would be great?
You are getting tagged as a spammer because you are sending the same message over and over. Set up your own mail server without a spam filter while developing if this is a problem.
You are not Yahoo -- don't pretend to be them! Set the From field to an address at the domain that's sending the mail (e.g, if your domain was example.com, send from something like inquiries#example.com or noreply#example.com).
This is probably related to SPF records. mail() will most likely try and send the mail directly to the server(s) identified by the MX record of the recipient domain, and because you are not sending from an IP address that is recognised as one of Yahoo's, Google will reject the email. If you are on *nix, you may be able to configure your system's sendmail program to relay via Yahoo. This is not an option on Windows (I don't think) because Windows has no sendmail and PHP will send the mail itself.
If you want a cross-platform solution you can use something like PEAR::Mail to relay the message through Yahoo's SMTP servers - this should resolve the problem as long as the SPF record is the source of the problem.
If your email is getting flagged as spam because of the content of the message, the only solution is to change the content of the message.

A couple problems re: CodeIgniter emailer

I have some problems with the email system for CodeIgniter:
First, the emails I send out (registration, confirmations) are getting caught in standard spam filters in gmail and other mail clients. How do I get around this? How do companies like Facebook get their emails through consistently?
Second, the mailer is working locally but once we deploy it it no longer runs (doesn't send emails) but all the other forms run just fine. Anyone ever run into a problem like this?
Thanks for all the help!
I can't really answer your first question - it's not specific to CodeIgniter. You just need to make sure your email doesn't look like spam. In short - there's no way of guaranteeing your e-mail will not end up in a spam filter.
As for the second question, I expect your production server needs to be configured properly for email. You probably need to configure CodeIgniter to send email properly. I would suggest setting up an SMTP server (or using an existing one) rather than using the standard PHP mail which I think CodeIgniter uses by default.
Regarding spam, most organisations are very secretive about how they prevent spam (not wanting to publish information which helps the spammers) and in some cases they don't actually know - an obvious examlpe of this is bayesian filtering - but, for example, hotmail use a completely unaccountable army of volunteers to manually classify emails.
Do and get a copy of spamassassin and try to reverse engineer how the standard rules work. Obvious things to check are:
1) AVOIDING LOTS OF CAPITALS
2) don't mention the 'V' word
3) make sure you've got a current and restrictive SPF 1.0 policy published
4) make sure your sending from an address which has A and PTR DNS records
5) Do provide a reply-to and from email address which use your domain in the address
the mailer is working locally but once we deploy it it no longer runs
doesn't send emails
Which? These are 2 totally seperate things. If the code is falling over (if so why have you not provided the error details) then its likely a PHP version issue or a problem with the connection to the MTA (or the PHP mail config).
The latter is a problem with the MTA itself.
99.9% of problems reported as PHP mail failures have nothing to do with PHP and are problems with the MTA.
Enabled detailled error reporting for your MTA and see where it is failing.
C.
You may have to configure the email on your server differently than your local development environment. I've had to in the past.
There are two basic ways that PHP can send mail:
Via a UNIX program called "sendmail" (only on non-Windows servers and only if it is installed - check with your hosting provider)
Via a SMTP server.
If you've configured CodeIgniter to use SENDMAIL, check to ensure that the Sendmail path is correct. Your hosting provider usually provides this somewhere in their online documentation.
If you're using SMTP, you need to make sure that your server can contact the SMTP server. You can do this by logging into the server via SSH and typing "telnet your.smtpserver.com 25". If you get an error message about not being able to connect, you know you have a problem with your hosting provider connecting to your mail server.
I've been able to diagnose this problem by enabling logging on my production server (http://bit.ly/4pprd6) and adding log_message('error', $this->email->print_debugger()) right after I attempt to send a message.

emails not going out to all users

I have a few scripts that send out emails to my users, and for some reason not all users are getting the email. The site is not live yet, so its no big deal yet but I dont understand why. I have set up a few fake accounts, one with my school email, one with hotmail and one with yahoo. When I sign up with my school email I recieve the welcome email, but I get nothing with the other email accounts. The same thing with my 'forgot password' email. Only my school email works, yahoo and hotmail arent working...
I'm running on a Linux server with Apache. Using PHP and the kohana framework 2.3.4
Thanks.
EDIT: I am displaying all errors, I dont have an error with the actually sending of the mail (I dont think) since I get it in my school inbox. Im running off a hostmonster server.
Also, the emails were being recieved at one point, but now they're not being recieved AT ALL from those inboxes
There's a lot of possibilities. If your php code isn't spitting out any php errors (make sure you have the following settings.
error_reporting=E_ALL
display_errors=on
If you're not getting any errors chances are the request is reaching your specified mail server (or sendmail). This means it's either a network based issue, or the receiving servers may be rejecting your email (spam detection?) Make sure you're sending out at least a basic from: header as well.
I don't know much about Kohana, but if it's not sending the emails like you wanted, you might want to take a look at PHPMailer.

PHP mail() - Email not received

I have set up an AJAX contact form on a client's website.
The problem is that the email is not getting through to the client's inbox.
I set up the client with Google Apps (in the same way I did for myself).
I used the same contact form with my email address and it works. But with any email addresses on their domain it doesn't!
All members of the domain are receiving 'ordinary' emails.
What could be the difference that's stopping mail() emails getting through?
UPDATE
Ok so I managed to solve it. Turns out that using a CNAME to point the domain to the correct server wasn't enough for sendmail so I had to change it to an A record pointing directly to the server. Strange but true. Thanks for the help folks, you pointed me in the right direction :)
It depends on the both settings on your server and the server on the receiving end.
hotmail for example requires the use of correctly configured SPF records.
many mail-receiving servers (including hotmail) require the email to originate from a Fully Qualified Domain Name. It is very possible that your e-mails send from PHP do not comply with this rule. (there is a good chance they originate from 'apache')
see hotmail self help and hotmail postmaster info
PHP's mail() function does not include a lot of headers with your mail, so you will need to supply them yourself.
The more hops your mail makes on it's way to it destination, the more likely it is to be tagged as spam.
So it might be a better option not to use PHP's mail function and instead use a mail library that connects to an SMTP server just like your desktop mail application does.
All in all, I would place my bets on an external library: Pear::Mail (documentation)
You could also read: how do you make sure email you send programmatically is not automatically marked as spam
UPDATE
Failing the SenderId or SPF check can get your message dropped before it even hits the users inbox. The message will not end up in the users junk folder, it will go directly to /dev/null.
I know this is at least true for hotmail and live mail. I see no reason for other hosts not to have implemented the same policy.
I recommend using PHPMailer (including their SMTP) library instead. It is reliable compared to mail and allows you to create fully customized emails.
http://phpmailer.worxware.com/

Categories