unique id in imap php - php

I am using imap_search to get a list of Emails FROM INBOX and SENT ITEMS.
I have a grid that showing the Mail headers first ,when user clicks on one row i want to show entire content,like body,attachment etc ..
to achieve this there should be a UNIQUE ID for each messages.
how can i get UNIQUE ID for messages , i know about the SE_UID option will return the UNIQUE ID'S but UNIQUE ID are only in one Mail box ,
I can see same ID'S on INBOX and SENT ITEMS.
Please help me.
Note : I am using Codeigniter with Peeker Library.
Thanks.

The completely unique ID is made up of the mailbox name (eg INBOX), the UIDVALIDITY returned when a mailbox is selected, and the message UID.
You need to select the relevant mailbox and provide the correct UID to fetch the right message. UIDs are not unique between different mailboxes.

You can use the UID of an email to do operations on any email in any mailbox such as INBOX and SENT.
You can find more information http://phpmaster.com/exploring-phps-imap-library-1/ in this article

Related

Selective export from MySQL database

I've got a database called Members, people would register online entering their fullname, email address, phone number, etc. I made a hidden form where it would set random 4 digit unique number and register it with their data, then I send it via email. People would use these unique IDs to enter an event, only 80% came. I collected the IDs, now I have a list of IDs that belongs to the people that came to the event, I want to export all the rows of people who came using their IDs. Example: For every row that include number: 4293, 1932, 9382 = export. Is there's a way to do this in MySQL?
Following query should do the trick
select fullname from members where ID in (4293, 1932, 9382)

Email Notification System Using PHP MySQL

I am currently working on a project that requires sending email notifications to users. The way it works, users follow certain catergories of posts/group, whenever there is a new post or comment under the post category/group they get email message notifying them with a snippet of the post itself.
I am expecting to send upwards of 5000 emails daily. Is it effective to use cron job to fetch users and send the emails at intervals or is there a better means to push this email while avoiding blacklisting on my IP by email providers.
Below is my table structure
First Table
Notification
ID // autoincrement
message // the message sent to users
createDate // date created
Second Table
User_Notification
ID // auto increment
userid // Id of users
notification_id // id of notification from first table
status // 0 or 1
So whenever a post is added, I insert the notification in the first table (notification) and then fetch all followers of that group from another table (following) where i store userids and the group ids. I then insert for each user in the second table (user_notification).
My cron job fetchs like 20 records from user_notification table and also fetch the notification message from notification table. I also fetch user email from my user table.
$firstquery = $lnk->mysqli->query("select * from user_notification where status=0 order by id ASC limit 0, 20", MYSQLI_USE_RESULT);
$secondquery = $lnk->mysqli->query("select * from notification where id=$notification_id", MYSQLI_USE_RESULT);
$thirdquery = $lnk->mysqli->query("select email from user_table where id IN($userids)", MYSQLI_USE_RESULT);
for($no=0;$no<counter;$no++)// loop to send emails
{
$lnk->emailsender($subject,$emailbody,$usr_email[$no]);
}
Please is there any better way to do this?
Unless you have a very specific relationship with your ISP, it is extremly likely you will be blacklisted, or your e-mails will go straight to spam. It is difficult to establish mass e-mails as legitimate. You can use a mass mailing services API to do some of the dirty work for you, like mail chimp or constant contact.
So the code you have will most likely work, minus e-mailing bit which should be done via a mailing service and their associated API.
5000 emails a day is roughly 4 emails per minute, or one email every 15 seconds. If I were you I would write a cron routine to run every minute that will send the emails which are due to be sent. This will ensure you avoid being treated like a spammer for sending out 2500 emails quickly, for example. It also means your users get email notifications quickly.
You could also send out the emails as soon as a user gets a notification, bypassing the need for a cron routine however if your site hits a surge in activity for whatever reason you could find some emails don't get through.
You could also consider using a 3rd party service like MailChimp which already has good authority with email providers, however that comes at a price and for 4 emails a minute I wouldn't consider it worthwhile.

display number of emails sent using php mail function

I am creating a real-estate website that displays properties. On each property listing I would like a button that says 'Express Interest', when clicked, this button should send an email to me containing the user details who expressed interest (the user will be logged in and so all their details will be taken from their account).
I have the email function working fine, HOWEVER, I also want to display the number of people who have 'Expressed Interest'. Is there a way to track how many times an email has been sent using this button and display "xx people have expressed interest in this property"
Store in the database before sending the mail and just before sending the mail include the number of people or the people who are interested, a simple query would suffice, or if you have a content management system you can include it there, in both cases you would need an intermediate table (connection between user id and real-estate id)
I would add another table to your database that stores a property_id and a user_id. If a user clicks expresses interest, you add another row to that table with the current property_id and the current user_id. To get the amount of links you simply count the rows
SELECT count(user_id) FROM interest_relation WHERE property_id = 'your property id'
This way you can also find out which user is interested in which property.

sending an email to the user depending on statusmy

i created a table in the database (mysql),and i write a code for inserting data in the datbase using php.values are inserted properly.here i set the status column value as deactive.when user created in that time ,we send a mail to the user to active the link ,means my site and then status column has to changed as active.
my db table contains the following columns
name,email,pwd,status,lastlogin,security qun,ans
when user is created in that time i set the status as deactive.in that time i want to sent a mail(in this mail,i want to send the link to their account) to the user to active their account ,then only user goes to the next process.after that when user open the mail & click that link,the status column has to changed as active in the database.how can i do this,anyone help me..
one way to solve the problem is:
make the field 'status' as varchar not int.
when you are inserting user information for the first time, make a random string and insert it in the status field.
say your random string you have created is 'lka342lkjasd8234kl2324ljklj2'. send the link with the string as a parameter.
when the link is clicked in the script check the verification string matches the value in your status table.
if it matches then show message that his account is verified and change the value of the field to 1 (as 1 indicates a active account)
if the string doesn't matches then show message the verification link is wrong.
in another way you can make another table for storing verification string. and make the status fiend an integer. set 0 initially and make it 1 when verified, and check the verification with the new table.
You can create column called activation_code, send an email to user with link, which will contain this activation_code. Link like this www.example.com/active.php?activation_code=AABBCCDDEEFF, when user click this link you can get activation_code, find a user at database and change status. Also you can create column activation_expires which will contain a date when activation code will expire.

How to make an email update the database?

I'm creating a site in PHP and MySQL that when an image is emailed to us at adress#example.com from someone's phone, I want the image to be automatically posted to their account page that is tied to the email address that they registered with us.
Also, I would like the subject of the email to determine what category the email falls under. So lets say the email had the subject of 3. Then it would give it the category ID of 3.
So lets say we have a users table with
user_id
email_address
name
and an image table with the following fields
image_id
category_id
user_id
image_name
The category table will be
category_id
category_name
Is there something I need to be doing with our mail server? Also should I be storing the image in the database or as a file?
This site will not get a lot of traffic and will only be used for one weekend. I'm guessing no more than 5000 images but I could be wrong.
Look at procmail for passing emails into scripts. Images should definitely be stored as files. You'll have to parse the email you receive and base64_decode the appropriate chunk to get the image data.

Categories