A couple problems re: CodeIgniter emailer - php

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.

Related

mail () SMPT error (5050) sending failed 5.1.1) PHP

I am having a problem that I have never encountered in my life.
In practice we have a website where we receive reservations, the A record is pointed towards our vps for the management of the site instead the part of mail is managed by aruba since the customer has preferred to leave their mail client. (for a matter of convenience because they have been using it for some time)
Going to the problem ..
the php mail () function when trying to send an email to the email: info#dominio.it our server returns as an error:
SMPT error (5050) sending failed 5.1.1)
in practice it is as if the email does not exist and was looking for it on our server but in reality it is located on aruba.
How can I tell the php mail () function to search for this mail not locally but on aruba?
with regard
Fabrizio C.
This only lays partial in php itself. You php.ini configuration file allows you to set a few settings
See:
https://www.php.net/manual/en/mail.configuration.php
The rest of the configuration need to be done in the MTA(Mail Transfer Agent) as in outgoing emails server of your VPS. Hard to say what you are using there..
Also according to your text, it looks like you tink the a record had something to do with your email...
a correctly configurated MTA does the following on an email address.
username#domain.tld
It requests the MX requests of domain.tld, and does not use an A record.
Then tries the MX records in order of their priority to deliver the email.
(This also is outside the scope of PHP, but might be good to know)

Mail() SMTP Server Response Error

I'm relatively new to creating and sending email messages using php so I could use some guidance from the experts. I've been working on an application for my web site that would allow visitors to place themselves on a mailing list to receive periodic newsletters. As far as I can tell, it should be working. However, I get the following error message when trying to send a test message
Warning: mail() [function.mail]: SMTP server response: 554 Sending address not accepted due to spam.
From what I can see, this problem has been addressed with other questions on this site, essentially indicating that I have somehow found myself on a spamming blacklist run by my hosting server (hostgator). I contacted their technical support group earlier today in an effort to get this resolved. After I explained the problem to them, they asked what SMTP settings I was using. I thought this to be a strange question as I am not sending these messages through Outlook or other email software but directly from my web site using php mail(). Their solution was to provide me with a domain name to use for my incoming and outgoing mail servers as well as specific settings to use.
Here's where the confusion comes in. I'm not sure how I can use this new information in my php code for sending an email. Am I supposed to put some of this information into the headers accompanying the message? As I understand it, using php mail() causes the message to be sent from the host servers and any changes that I make to the email software settings on my home desktop should have no effect. Other than assuming that the individual that I spoke with at hostgator doesn't understand my question and trying to get a different answer from a different technical support specialist, I am at a loss as to what to do. Any suggestions?

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!

Fast email delivery

I have a website that receives incoming emails via cloudmailin, adds the content to the database, and then sends a confirmation email back to the person who sent the email. Currently I'm using a php mail() function to send the reply, but it seems to take about 1.5 min to actually get to the user's inbox. Is there a way to make this more instantaneous? I'm currenly hosting the application on FatCow, and I'm sure it has to do with their mail server, but I don't really know much about how that works and am wondering if I have to change hosts to accomplish faster delivery times or if I can do anything about it without switching.
mail() is a black box. You're telling PHP to try sending a mail however the host has configured PHP to do so.
It's very likely that it's just calling sendmail in your case. It's also very likely that the mail queue on that machine isn't the fastest in the world. Shared hosting machines are often overloaded.
The very first thing you should do is ask your host about the mail delay. Perhaps something is wrong, and they can fix it. Or they might just tell you that a minute and a half is not a long time to wait.
There are lots of other options, mostly in the form of companies that provide an SMTP service to you. I can't recommend one, but I can recommend that you pop over to your favorite search engine and look for "smtp service." I've recently starting working with Amazon Simple Email Service. It's supposed to be fast and well-maintained, and it's certainly inexpensive.
All of those options are likely going to require some configuration changes on your end. For example, you'll want to set up custom DNS records (for DKIM and SPF) to ensure that mail from a third party provider isn't automatically flagged as spam.
Using SMTP with PHP is dead easy. There are plenty of mail generating options out there. My personal favorite is SwiftMailer. It even has a transport option for Amazon SES.
The final option, of course, is grabbing your own virtual private server or dedicated server, which will let you configure outgoing mail as you desire, at the cost of needing to know how to maintain that server.
Edit: Obligatory link to relevant Coding Horror post.

Which email service shall I use for testing sending emails?

I'm coding in PHP w/ CodeIgniter and I'd like to test some of the features in my app that send emails.
For some reason, I couldn't send emails through my email account in my local server (XAMPP), and I also don't want some SPAM filter to think I'm spamming while I'm testing.
So is there any email service that I can use for testing purposes? preferably one that doesn't enforce SSL, since I have problems getting that to work on my local server.
Appreciate your help.
As long as you're not sending out dozens or hundreds of test E-Mails, use whatever your everyday E-Mail provider is (e.g. GMail). Set the SMTP server of your mailing function to point to Google's. (I think SSL is optional with GMail, but I may be wrong.)
If your mailing library doesn't support using an external SMTP server, switch to a different one. But I think CodeIgniter has you covered there.
If you just want to test the application functionality, check out Papercut. This utility simulates the sending of email without having to set up a mail server, works great!
edit: had wrong link.
I like to set up a test SMTP service on my development machine and just send to that. There are several good options listed under this question.

Categories