Mail() SMTP Server Response Error - php

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?

Related

Service which presents your outgoing email as a draft email when testing on localhost?

Lots of answers here and elsewhere on Google for how to setup your WAMP or XAMP on localhost to send emails.
However for testing/developing, you mostly don't care about emails actually getting transmitted. You just want to check how they're formed, and whether the email picked up the correct settings and options.
So, I remember having this problem a few months ago and finding a solution/service which did this:
As soon as my PHP code triggered an outgoing email, it would present it as a real draft email in a new window in my email client (Outlook, as it happens). I could check the from/to/subject/body instantly and easily. Nothing actually got transmitted, and I didn't have to keep a bunch of inboxes open somewhere or worry about delays or junk folders.
Trouble is I can't remember how I set this thing up. It was either a service which I downloaded and installed or it was a tutorial on how to set this up in WAMP. It was possibly a WordPress plugin but I'm not sure. I am certain it was free.
Does anyone recognise this kind of setup for email testing in PHP?
Are you sure it is a PHP configuration and not a software?
I used a mail smtp 'catcher' that works as you describe.
I hope it could be useful for your interests: Test Mail Server Tool (http://www.toolheap.com/test-mail-server-tool/)
I'll be accepting Nacho's answer. For completeness ... following StackOverflow's Related questions and checking out some other answers, I see there's also a service called Papercut mentioned here, which I might also check out.

Record/copies of PHP mail() previously sent from our website?

Should there be a record of all php sent mail (via our hosts mail() function) anywhere?
Our web developer made an oversight and all enquiries sent via the our host's (godaddy.com) mailer relay for the last 2 months were rejected by our local mail server. Naturally, our server doesn't keep any rejected emails.
I have spoken to godaddy.com and they claim there is no record, however I'm not particularly confident with the answer.
Is there anything I can do? The enquiry form is now fixed (used Mandrill), so that's not an issue.
No, the mails are gone now.
Rejected mails that a mail server tried to send usually go to the mail admin account of the sending server as a bounce - however, even that account might not be set up or failing or rejecting mail, so the mail server will get rid of these undeliverable mails that double-bounced by deleting them from the queue.
You might get an idea of what was tried to mail if you are able to get your hand onto a mail server logfile, but assuming this is in the hands of your hosting provider, your chances are low: 1. these logs would only give you an idea of which mail addresses were involved, but no content. 2. the log files usually get deleted quickly because they'd serve no regular purpose.

Distinguishing fake emails sent with PHP via postfix on a CentOS VPS

I am going through my first steps on VPS management and configuration; been able to install PHP, mySql, phpMyAdmin, postfix, etc ... and migrate a Wordpress from an existing shared server to this VPS.
Sorry for my question being naive, but when testing postfix with the php mail function, I purposely sent the email with a "From" header which was not my own email address (don't worry, nothing serious).
Question is: the email was sent and received in my inbox as if it was sent by somebody else! Is it this easy to send a fake email with php and postfix? (of course, checking email headers reveals the truth).
How can I restrict my VPS from being able to send emails from arbitrary addresses?
Thank you.
The answer is "yes and now": it is easy to "fake" emails, though that actually is not faking at all. Please understand that the "From" and "To" addresses shown inside an email message are part of the messages content. From a technical point of view these addresses have nothing to do with from whom (from which account) that messages has been sent or to whom it is addressed. Those addresses (accounts) are specified on a completely different level.
In addition it is not up to the sending software to decide what is a valid message and what not, in terms of a message being genuine. That obviously would not make sense if you think about it. That is something that either the receiving side or the transmitting side have to make sure, here the email servers, especially the smtp servers accepting and routing messages.
And indeed this is the case: it is a question of your local smtp servers configuration if such a message is accepted for delivery or not. Most likely the message in your test case has been accepted because it originated from within your local network, or what the smtp server considers as your local network. For such messages typically other rules exist compared to routes received "from the outside" and this does make sense.
Further it is a well known fact that it is part of the responsibility of the smtp server administrators to make sure that their servers cannot be missused. The rules used for this are called "relaying rules", all current smtp server implementations offer configuration opions dealing with that issue.
In general you can say that
really "faking" an email is not that easy if you look at the details. If a receiver only looks at superficial details then indeed he can easily be fooled.
email is not at all a secure means of communication, it never has been and it never was meant to be. It is built on trust in general.
the only secure way to make sure that an email has indeed been sent by the party that is claimed as sender inside the message is by using "signed messages", by using a digital signature.

Email sent from form is not delivered to recipient

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.

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.

Categories