I use PHP mail() to send out emails quite often. I recently found out that if you create your email as one long string without line breaks, you'll get random exclamation points in your emails. I was recently pointed towards RFC 2822 section 2.1.1 for the solution. It appears that no line can be longer than 998 characters without a line break.
How do you fix this? (1) The first way is to base-64 encode the data (best solution for plain text emails to retain long lines). Check out this blog for some info on that. (2) The other, much easier way, is to simply insert line breaks in your email (best solution for HTML emails where long lines are not needed). Add a "\r\n" to the end of each line in your email to make sure you never go over 998 characters.
Showing posts with label email. Show all posts
Showing posts with label email. Show all posts
Friday, April 9, 2010
Tuesday, April 28, 2009
email piping with PHP and cPanel
I had a lot of trouble piping emails to a PHP script today. There was a real scarcity out there in terms of information (or I just didn't know how to search for the right terms). So, I thought I'd post about my fun in case someone else got stuck. (By the way, I use cPanel 11 and started with this script.)
What I wanted to do was set up an email address that would pipe to a PHP script. That is, my PHP script would get a copy of the emails. Then the PHP script could parse the file and do whatever; make a database entry or something similar.
I ran into two problems.
First, I would get a return email that said "Local delivery failed." It would have this at the top of the email:
I found some website somewhere that suggested changing the file permissions for the PHP script (emailin.php in this case). So that is what I did, and it seemed to help. I used the cPanel File Manager to change the permissions to 754.
That fixed this problem.
The second problem was that despite receiving the email at the script and doing the appropriate things with it, I would still get an error email back. So, even though it all worked, my email would bounce back saying:
Again, after a few hours of searching I found someone that suggested changing the hash bang at the top of the script file to this: #!/usr/bin/php -q
That dash q made all the difference.
This was my adventure.
What I wanted to do was set up an email address that would pipe to a PHP script. That is, my PHP script would get a copy of the emails. Then the PHP script could parse the file and do whatever; make a database entry or something similar.
I ran into two problems.
First, I would get a return email that said "Local delivery failed." It would have this at the top of the email:
pipe to |/home/accountname/public_html/emailin.php
generated by msg@accountname.com
local delivery failed
I found some website somewhere that suggested changing the file permissions for the PHP script (emailin.php in this case). So that is what I did, and it seemed to help. I used the cPanel File Manager to change the permissions to 754.
That fixed this problem.
The second problem was that despite receiving the email at the script and doing the appropriate things with it, I would still get an error email back. So, even though it all worked, my email would bounce back saying:
A message that you sent could not be delivered to one or more of its
recipients. This is a permanent error. The following address(es) failed:
pipe to |/home/accountname/public_html/emailin.php
generated by msg@accountname.com
The following text was generated during the delivery attempt:
------ pipe to |/home/accountname/public_html/emailin.php
generated by msg@accountname.com ------
Again, after a few hours of searching I found someone that suggested changing the hash bang at the top of the script file to this: #!/usr/bin/php -q
That dash q made all the difference.
This was my adventure.
Friday, September 12, 2008
Free Email
The next Google service that I would like to highlight is hosted email. This is a lesser known service offered by Google, I believe. However, it is probably the most powerful and most beneficial free service available to non-profits! Google offers free email service for any domain. Non-profits also get enhanced services that businesses have to pay for. You can get as many email addresses as you want, the SPAM protection is amazing, and each account gets over 7 GB of space!!
Once you set it up you get an administrator panel where you can manage all account information. And even though it is Gmail, all of your email addresses will reflect your domain name (e.g., name@your-domain.org). You can also customize it a bit and use your own logo. Additionally, you will get chat and other Google applications automatically. It can really boost in-office communication and efficiency.
I have used this service on multiple domains. I have set it up for the First Baptist Church of Los Angeles, and it has been a dream for them. Major universities have also started using it. Fuller Seminary, for example, uses it for all their student accounts.
Check it out. I really think you'll like it.
Once you set it up you get an administrator panel where you can manage all account information. And even though it is Gmail, all of your email addresses will reflect your domain name (e.g., name@your-domain.org). You can also customize it a bit and use your own logo. Additionally, you will get chat and other Google applications automatically. It can really boost in-office communication and efficiency.
I have used this service on multiple domains. I have set it up for the First Baptist Church of Los Angeles, and it has been a dream for them. Major universities have also started using it. Fuller Seminary, for example, uses it for all their student accounts.
Check it out. I really think you'll like it.
Subscribe to:
Posts (Atom)