Is It Easy to Make an Email Address Book Invite? - php

Twitter and Facebook invite new users to send an invitation to everyone in their Gmail, Hotmail, or Yahoo Mail accounts.
Is it easy to add this functionality to a website?
Thanks,
John

Last I checked you basically have to pretend to be a web browser then programatically log in to the site, scrape the contacts, then compose/send the message. It isn't difficult, but it is time consuming as each of these services works differently.
I does, however, look like people have written script for some of this though: example.

Yes!
What they generally do is to send in the email a special URL that contain a code, for example:
www.mysite.com?UserCode=ABC
That code (ABC) is associated to the email of the user so the application undestand which user is trying to subscribe. You must keep in a database the pair: email, code.
HTH

All of the above answers are correct, here is a summary and some more explanation:
You first need to get the user's login for each service you want to get contacts from (I personally don't understand why people would do that - I would never give my GMail password to Facebook, let along some little known web site).
Then you can simulate a login to the said website and grab their contact list as an export (all serious email services allow you to export the contact list as CSV or something). You can implement this yourself or use some external library such as contactgrabber mentioned by Haim.
You then go over their list of contacts and for each contact you generate a key (you want to generate a unique key for each email you send so you'd know who responded to you). Generating the keys is easy - take some info like the current user's email plus the target email address, add the current time and pass everything to a hashing function like SHA1 - should do the trick.
Now store in a database table for each contact you got: the inviting user's ID, the email address being invited and the key you generated.
Lastly send a nice email to each contact with a URL to your website's "invitation activation page" with the correct key applied - like so: http://www.somesite.com/invited?key=123456780abcdefgh
when that page is accessed, get the key from the URL and find it in the table - that would give you the email address that activated the invite and the user that invited them. From here you can take it to where ever you want.

Related

"Unsubscribe" link in email

I have a website where I send out surveys to people who want to take these surveys. They gave me their email address, so they do want to take the survey.
The problem is, our server had malicious code injected into a contact form and that resulted in a blacklisting problems. The blacklisting seems to be resolved, but now I'm trying to do everything I can to help make my emails look cleaner and not spammy. I'm using PHPMailer to send with SMTP authentication.
One important tip I've come across is to include an unsubscribe link. But these people aren't actually "subscribed." They will only be emailed to do a survey one time. So I was wondering if I put a link that leads them to a page explaining why they received the survey (basically remind them they game me their email) and just name it unsubscribe.php? Then I will name the link "click here to unsubscribe." Would that be sufficient?
You can't just send people random stuff because you got their email address. You need to have explicit consent to send them things for a specific purpose, and what's more, you need to be able to prove that they gave that consent. Such a record of consent effectively is a subscription, so an address obtained legitimately would never raise this question.
If they did give you their address willingly, but you have no record or evidence, it's legally indistinguishable from you having harvested it from a random web page.
To put it another way - if you don't have this provable consent, you can't legally send them anything.

How effectively send messages to a group of email addresses using a central address?

I have to set up an email sending solution, and I haven't yet figured out the best way to do this, I hope you have some ideas. I would like to achieve the following:
Have a central email address like mailinglist#mysite.com.
Behind this list there is a database of email addresses. I would like to be able to extend this list through an API. For example if a new user registers on my site, I want to add them to the list. Or if someone unsubscribes, I want to remove him from the list.
On my website I will place a button, and if the user clicks it their email client opens with the central address prepopulated.
If they send an email to this address, everyone will recieve it who is on the list.
If someone replies also everybody will recieve it.
(The application is written in PHP (Laravel framework) if that is important).
Do you know of any service where I can set up this kind of "mailing list", preferrably for free? (It would have a few hundred members, sending a somewhere around 30-100 emails a month.)
I guess you'll need root access to your (linux) webserver - then you can hook Sympa (read "list of features") into your MailTransportAgent (MTA) (postfix, exim) or whatever.

How to write a code that automatically get the respodent's mail id using forms..(like google forms but not using it) ...?

In Google forms, we have an option collecting the user_name (i.e mail id) of the respondents.
What is the code for having the same feature but using other form developed using HTML, etc..
You'll have to ask them for it. There is no universal, automatic way to get a user's email address — it's only possible on Google Forms because the user is logged into Google with their account (which has an email address associated with it).

PHP / MySQL Ticket Response - Store E-mail repsonse in database?

I am building a basic support request system where the customer can log in and ask a question and an admin can go in and reply and it will set the status to "Responded" and e-mail the customer to let them know someone has responded.
My question is.. I have a "comments" section which is a log of the interaction between the admin and the customer. If I e-mail the customer the initial response from the admin, then I have a feeling they will just hit "Reply" from their email and start communicating through there, and the logs won't be stored.
I could either e-mail the customer and say "Log in to view the response", or maybe if the customer does hit reply I can somehow track it and insert that in the comments table like they did it from the website. If that is even possible?
Just wondering if there is a standard way to do this and any suggestions you may have.
Thanks!
When sending the email to the user you can have it sent from an email address created for that specific ticket. Something that can identify it with your email system to help you route it back to the php ticketing system.
support(ticketnumber)#domain
support12345#mydomain.com
Then it depends on your email server how to go from there.
There are several useful tips at this question that may help or get your started.
How to get email and their attachments from PHP
If you want their reply to be automatically inserted into the DB, you'll have a assign a cron job in your server to run a php script to detect whether there's a reply from a customer (you need a table listing the customers' email and names.
Each time a customer uses the ticket system their email and name goes into this table).
You'll need to connect to your Inbox too via imap or SMTP, and there are scripts to do this (phpmailer, swiftmailer, etc) and "walk" through each email and see if the sender email matches any in your customers table. Then so an INSERT to the comments table.
Anther way is to read through the emails each time the comments page is loaded, but this will cause the page to take longer to load. However, the data will always be more "real-time" compared to cron jobs.
You could use email piping (if your server supports it).
In the subject, you'd have a unique identifier which contains the ticket ID or something unique to the ticket. Example: "How do I eat food [Question: #1234]", where 1234 is the ticket ID.
In your control panel, you would set up an email forwarder to your email piping script.
This tutorial offers the basics to email piping, and I used it as the base for my piping script: http://www.damnsemicolon.com/php/parse-emails-in-php-with-email-piping-part-1

How do I set up an inbound mail controller so users can post to unique email address?

Tumblr (the short form blogging platform) has a feature where you are given a unique email address (for example, f3sf16a#tumblr.com) that you can email text or images and it automatically formats it into a post for you (as long as the sending email address matches your account email address).
I'd let to set up something similar, but solely as a method to submit images. Ideally, when a user signs up to my site, I'd create a unique address for them and store it in my db (MySQL). If a user emails a photo to that address using the email address they signed up with, i'd route it to a PHP function that breaks it down and handles the upload of content to their account.
How would I go about setting something like this up? Would it be something at the DNS level, or Apache level? Would I need to create a "safe list" of all the "real" email accounts on my domain to pass it through first? Also, I'm using Google Apps for email on this domain, will I need to create some sort of filter on that end?
Any ideas/suggestions would be awesome!
There's another quick and dirty way to make this work...
Setup a "catch-all" address for your domain. In other words, setup your domain so that e-mail sent to any address at the domain automatically gets forward to one catch-all address (i.e. global#mydomain.com).
Then, on the PHP side... Setup a script that periodically checks the e-mail in the global#mydomain.com box. Be sure to check the "To:" field so that you can identify which specific user the message was intended for.
Hope this helps!
It would be at the MTA level. Most MTAs have a facility whereby an email can be piped to an external program; this program would then parse the email and store the image.

Categories