PHP - How to add stuff from a database into a newsletter? - php

Hey guys. I need help for a project for school. Essentially, I need to write a program that sends newsletters. I can send the newsletters and stuff, but the main issue I'm having is that the newsletter needs to contain things that are contained in a database. How exactly do I draw those things and put them into a newsletter? The bulk of it needs to be in PHP, but Java and stuff can be used, if needed. Also, I cant install anything on my portion of the schools server, so I cant use any CMS's and stuff.

Unless you are writing this for fun and learning, don't do it.
You will get your IP blacklisted and have lots of problems. there are regulations (CAN SPAM etc) and best practices (SPF, domain keys etc) you need to follow if you want this to be successful. Otherwise you will not get any of your mail delivered, and possibly a call form your ISP.
How do you handle unsubscribes? How are you going to handle bounces? Mail loops? Blacklisting of problem addresses? This is not a simple topic.
You would be better off purchasing a email management system;.
Lyris makes one that you can install. There are other free/open source projects as well (majordomo, mailman etc).
Heed these words intrepid e-mailer!

Hey, do you have basic problems with querying your content from your database?

Related

import email data to the DB

I built support system (web) where my helpdesk can open new tickets/issues.
I want my clients to be able to send email with the issue text and file attache, to specific email address, and new ticket will be opened in my system.
For that I need to know how to scan the folder and how to add the email data to my DB.
what do I need to look for, in the internet, for that? what is the subject?
(I'm using PHP)
As the other's have commented, it's likely a larger task than you're ready to handle. But it doesn't hurt to try.
If I was tasked with the job, I'd take advantage of Gmail (for it's spam reducing features and large storage) to accept incoming email. From there, you simply need to setup a script that connects to your email account and processes the email for storage in your database.
Normally I recommend a solid library for making the job easier and cleaner, but I have a suspicion that you may not be familiar with OOP. If you at least know how to utilize classes, then check out Github:
https://github.com/search?l=PHP&q=imap&ref=searchresults&type=Repositories
Otherwise, if you're new and don't mind writing something "messy" then the following should at least point you in a good direction:
Connecting & retrieving emails for IMAP:
http://www.php.net/imap
http://www.php.net/manual/en/function.imap-open.php
Fetching/processing attachments:
(note that attachments are part of the email body)
http://www.php.net/manual/en/function.imap-fetchstructure.php
Storing attachments (in the filesystem):
http://www.php.net/manual/en/function.mkdir.php
http://www.php.net/manual/en/function.file-put-contents.php
There's plenty of Googling left for you to do. So go forth and make a lot of mistakes. Read the manual. Kick yourself for not having read it sooner, then go make more mistakes. Isn't that how most of us learn?
The first thing that comes to mind is to pop the most recent emails if you have pop3 set up or use imap functions. I did something similar to this using c# using openpop.net. So that could be a starting point.
You can use this method, using the cURL to fetch the emails from Gmail server through feed atom. XML response will return and we can convert it to HTML.
http://www.code4share.net/items/get-unread-email-in-gmail-by-php/XRGXVVh.html

Would it be a good idea to set up a newsletter sign-up form in simple PHP?

I would like to add a form that allows my site visitors to sign up for a newsletter from my site.
I started to build the form, but apparently it's not such a good idea and instead I should use prebuilt scripts by other people to do this as they would be more secure.
Would it really be all that bad to make my own and just have it query all the signups into a database? I don't want it to be all that complex, just need something simple, but I definitely don't want to jeopardize the security of people signing up.
Thanks!
You can do it yourself if you know how to write it correctly.
The reason why people use tried and tested code is because you may be black listed by email services due to large volume of emails you would be sending. Once you are black listed then it is difficult to get yourself off the black list. The tried & tested code SHOULD send the newsletters out periodically rather then mass emailing at once.
Other reasons is due to security, if you write the code incorrectly or if you are new to forms which access databases, then it may not be sensible to write your own. It is good practice to learn it though, even if in the mean time you have to use someone else's code.
You also have to verify emails addresses by a confirmation request email and an associated form. In addition if you have a larger list (more than a few hundred members), then you must code bounce handling and unsubscriptions. For a small list you can do these manually. I did build such a web application step-by-step, but if I had to start it now, than I would consider an existing mail list software more seriously. At first I also thought that I only need a small form, and the list managers I checked was indeed difficult to integrate, but in the long run it was too much effort.

contact collection - php, mysql, mail server

I am building a project assuming that there is a method for intercepting incoming and outgoing mail from a mailserver. If it is not possible please let me know, I am new working with mail servers, so any material that you could provide would be greatly appreciated.
I am building a project to manage contacts and the organization's interaction with them throughout a broad range of services. I would like the creation of the contacts be as automatic as possible. In this sense, what I had thought would be interesting was to create a page that would intercept all incoming and outgoing message from the org.'s mailserver. The intercepted data would be stored on a MySQL database.
Is this possible in PHP? Would this be the correct way of going about it?
What I'm looking for is a place to start looking and learning. Reading materials, tutorials, case-studies, etc. Whatever you can send over to help me get closer to my goal. Also, if the method I've described above is flawed, or you can recommend a better method, I'd be willing to hear your thoughts on that as well.
If so have a look at PHP's IMAP functions as they provide everything you need to be able to do this quite easily.
Have a look at http://www.php.net/manual/en/ref.imap.php and ask any specific questions about the functions used you may have.

What to use as "spam-filter" when sending emails with PHP mail()?

I have a classifieds website, and on each classifieds page, there is a form for tipping a friend where you just enter the persons email-adress and the tip will then be sent. The form is submitted to tip.php where all "magic" happens with checking and sanitizing etc etc...
Lastly I use php:s mail() function to send the email from tip.php...
Now, I wouldn't want spam-bots and automated robots etc to send mail and blacklist my server.
What should I do?
One method which I would rather NOT use is logging IP:adresses of senders in a table (MySql) and then allow only x emails per sender.
As I said, the above solution is nothing I would prefer, there must be an easier way.
Is there any method you know of?
Is there any application to install maybe, on a linux server which does the job?
Thanks
I would say that the most used method would be captcha. This will ensure that the one that sends the email is a man, but everything can be cracked. So I would recommend to find a really good one, just type captcha into google and you are good to go. Also you can use another method/thing to make it more viable, e.g. some question that can be answered a simple mathematical problem, etc.
I think you should do something in the form which makes it difficult for robots to submit rubbish into it.
Either a piece of Javascript which robots don't run (Hint: The usually don't) or if you MUST, a captcha.
You should definitely monitor the use of this facility, as well as monitoring outbound messages, message queues, and watch for bounced mail though.
Quite a lot of web spam seems to come from humans who are paid to submit rubbish into peoples' forms, which is difficult to block.
You can of course, also use something like Akismet - an API where you can ask them to spam-scan form input; I'm sure its licence terms are very reasonable and if spam is a real problem, paying for it will be acceptable to management (using Akismet is much cheaper than paying expensive developers to write and maintain an in-house anti-spam system)
Unless its a paid for service or you can restrict the recipients to a pre-approved list and can establish the bona fides of the users I would strongly recommend you don't do this. However...
Do have a look at spamassassin - but remember that one of its most important metrics is the Bayesian filtering engine - which needs to be trained using heuristics (but you can run spamassassin for your incoming mail and copy the database to your webserver).
Do make sure that you only allow authenticated customers (with an authenticated email) to use the facility, and limit the rate at which they can send messages (and the number of recipients) using a dead-man's lever.
C.

PHP/MySQL mailing list, mailer and subscription classes

I am working on a project that needs a emailable mailing list built into it with a very complex list structure. Originally I thought I could just use PHPList to do the job with some minor alterations because of its list management. But now I'm finding that I'm going to need to build this from scratch. PHPList is way to complex to make tweaks to.
So I'm looking for recommendations of scripts, classes, functions to help with the processes so I can just focus on the logic and list management.
The requirements are as follows:
User Subscription web form that captures name and email. Double opt-in that sends a confirmation email with a link back to a landing page. (Looking for a simple script to manage this aspect).
Landing page for opt-in confirmation from subscription email. This is where I need to include my list structure. The lists are very deep nested set trees and way beyond the scope of any mailing list I've come across. I'll need to build this part as it is too complex.
User login for future tweaking of their list settings. Would like a script to help with this aspect.
Admin page for constructing the email (html format). Looking for a simple script to help with this process. The site uses CKEditor for most html input so I could just end up using that here. I also then need to link it to the nested set tree list so I'll need to construct this portion myself. Looking for a simple class/script that I can use as a starting point to help with the structure.
Mail manager script. Ideally would like a cron job option to send the emails at a certain time each day/week. Also would like it to stagger the emails with a pause every 25 or so to bypass spam flags. A log file of what got sent where would be ideal. I'll need to construct the logic of what gets sent where because of the list structure. Would like an existing management script as a starting point.
Mailer script. Finally need a class/script to do the actual sending. I've used phpmailer in the past but wondered if there was anything better nowadays.
As I said at the start, PHPList is reasonably close but was far too complicated in its structure to be delving and changing the way it handles the lists. As such I'm looking for scripts that are user-friendly to tweak and hack.
My 2 cents on this:
use utf-8 for all the system
normalize your emails
create a master suppression list
(many domains wont like you sending
emails to them. with this you can
avoid send emails to people who
probably will block you)
sending emails: create a queue:
divide the process in stages: email
rendering / email sending / etc
phpmailer is enough good
abuse of the use of the
"List-unsubscribe" header and many
others
create a really good bounce handling
script (since keep sending to bad
addresses kill the reputation)
setup you rdns for all your sending
ips
use spf and DKYM
clean the email's body from bad
user input.... some users will try
to send "embed" tags on the body..
that kill the sender reputation
follow all ISP/ESP instructions
about: email per connections /
timeouts / etc ..... yahoo! has it
as many others ISP

Categories