I am sending email to some users and wants to know who had read it, means if some one had read that email then a log file will maintain which contain the email address of that user with date/time/IP.
For this I send a javascript function with the email (html template) which just alert the email address of the user when ever a user opens that email like:
for($n=0; $n<sizeof($checkBox); $n++){
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->Subject = $subject;
$function = "<script language='javascript'>function stats(emailId){alert(emailId);}</script>";
$bodyOpen = "<body onload='stats(".$checkBox[$n].");'>";
$msg_body .= $body .= "<table><tr><td>Hello Everyone</td></tr></table></body>";
$mail->Body = $function.$bodyOpen.$msg_body;
$mail->WordWrap = 50;
$mail->FromName = 'Muhammad Sajid';
$mail->IsMAIL();
$mail->From = 'webspot49#gmail.com';
$mail->AddAddress($checkBox[$n]);
$sent = $mail->Send();
}
the html template works fine and shows an alert popup on page load but it does not works if I use to send this html template.
And I only want to solve this issue using PHP5.x.x / javascript, no other software or third party tool.
Any help..?
Add Header to email:
Disposition-Notification-To: you#yourdomain.com
As mentioned above it's not reliable and it's better to do something like this:
<img src="http://yourdomain.com/emailreceipt.php?receipt=<email of receiver>" />
And log it in a database, although again this is restricted by the email client's ability to show images and sometimes it may even put the mail into junk because it doesn't detect an image... a workaround that would be to actually outputting an image (say your logo) at the end of that script.
Edit:
A quick lookup at the phpmailer class gave me the following:
$mail->ConfirmReadingTo = 'yourown#emailaddress.com';
but it's the same as the Disposition-Notification-To method above.
Send a beacon image in the emails like so
<img src='http://www.yourserver.com/beacon.php?email_id=$email_id&email_address=$user_address' style='width:1px;height:1px'>
And then use the beacon.php file to log the data. You will then want to output a 1X1 image with appropriate headers.
Important note Many popular email clients (such as Gmail) now block external images, so this is by far, not fool proof.
This is next to impossible to do 100% effectively.
You could control where the content is stored e.g. http://www.example.com/34hg038g85gb8no84g5 and provide a link in the email to that content, you can then detect when that URL was viewed.
Use a method used by MailChimp and other newsletter campaigns, put an invisible image in your email, this image should reside on a server you control, you can then detect when that image is hit when the user opens the email.
It is not possible by definition.
Mailreaders are not browsers, they don't support javascript. They don't even support proper CSS so dont expect too much. So I honestly don't see any way you can do what you're trying to do
I just add a single line:
$dt = date('F \ jS\,\ Y h:i:s a');
for($n=0; $n<sizeof($checkBox); $n++){
$mail = new PHPMailer();
$mail->IsHTML(true);
$mail->Subject = $subject;
$src = "<img src='msajid.isgreat.org/readmail.php?dt=".$dt."&eid=".$checkBox[$n]."' />";
$msg_body .= $src .= "<table><tr><td>Hello Everyone</td></tr></table>";
$mail->Body = $function.$bodyOpen.$msg_body;
$mail->WordWrap = 50;
$mail->FromName = 'Muhammad Sajid';
$mail->IsMAIL();
$mail->From = 'webspot49#gmail.com';
$mail->AddAddress($checkBox[$n]);
$sent = $mail->Send();
}
and in readmail.php file simply insert date/time and userid with a check (if not exist with attached date/time) & fixed it only for Gmail, hotmail but not for Yahoo...
Can some one help to also fix for Yahoo....?
Haaaa.
silly mistake just use complete url like:
$src = "<img src='http://www.msajid.isgreat.org/readmail.php?dt=".$dt."&eid=".$checkBox[$n]."' />";
and it will also work for Yahoo....
While I didn't discover exactly why the simple PHP file wasn't generating the included image (as mentioned in my post 6 hours ago), here is another very complicated way of generating an image file that wasn't rejected by my own PHP 5.4.30 web server.
Here is the code that I put into an index.php file within an /email_image/ subdirectory:
<?php
$message_id = $_REQUEST['message_id'];
$graphic_http = 'http://mywebsite.com/email_image/message_open_tracking.gif';
$filesize = filesize( 'message_open_tracking.gif' );
header( 'Pragma: public' );
header( 'Expires: 0' );
header( 'Cache-Control: must-revalidate, post-check=0, pre-check=0' );
header( 'Cache-Control: private',false );
header( 'Content-Disposition: attachment; filename="a_unique_image_name_' . $message_id . '.gif"' );
header( 'Content-Transfer-Encoding: binary' );
header( 'Content-Length: '.$filesize );
readfile( $graphic_http );
exit;
?>
For the image filename, I used the following:
http://mywebsite.com/email_image/?message_id=12345
Within the email_image folder is also a blank 1x1 gif image named "message_open_tracking.gif".
The index.php file can also be revised to make use of the message_id in order to mark that message as having been read. If other variables are included within the querystring, such as the recipient's email address, those values can also be used within that index.php file.
Many thanks to Bennett Stone for the following article:
http://www.phpdevtips.com/2013/06/email-open-tracking-with-php-and-mysql/
I know this is an old thread but I just had to respond... for those of us who must consider this, I suggest we put ourselves in the place of the people who have to write the anti-spam software to thwart our efforts. Detecting a ? or a .php (or other script/binary extension) inside an image tag would be trivial for me as a postulated 'spam assassin' programmer... just as identifying a 1x1 image would be...
I spent 2.5 yrs as National Digital Director for a presidential campaign that raised $20 million before we even had a candidate -- here's what I had developed for that campaign:
At send time (or before), generate a hash on the TO: email address and store that in the db next to the email address.
Use the hash we just generated to modify a small, but plainly visible logo in the email and make a copy of the logo with the hash in the logo file name eg: emxlogox.0FAE7E6.png - refer to that unique image in the email for the logo - make a copy of the logo with the hash name in the filename. This particular logo series only ever appears in targeted mass emails. Warn crew members not to copy it for other purposes (or to rename it extensively if they do). The first part of the filename needs to be something that will not appear in the logs in other contexts to speed your parsing and the code you have to craft to sort out false hits.
Parse the logs for occurrences of the logo being requested, and extract the hash from the filename to match back against the one email address. And your parsing program can also get the IP address and the time delta it took for them to get and open the email so you can identify highly responsive recipients and the ones who took a week to open the email. Do a geo-lookup on the IP and see if you get a match with the location you already have, and/or start recording their travel patterns (or proxy use patterns). Geo deltas could also be identifying email forwards.
Same hash, of course, is used to record clicks, and also the first and second opt-ins. (Now you have a 'dossier' of multiple opt-ins for responses to those abuse reports and you're protecting your email reputation, too).
This method can also be used to identify who forwards emails to their friends and you ask those 'good forwarders' to join some kind of elite digital volunteer crew, offer them discounts or rewards or whatever is appropriate for your business/project... in essence, that same hash also becomes a referrer code.
You can also ask them to right click on the logo in the email and save it without changing the filename, then post it to 'wherever' (the image should have a memorable, readable, meaningful shortlink on it, not an unreadable bit.ly shortlink). You can then use the Google Search API to identify who helped you out in that fashion and thank them or give them rewards... For this purpose, it helps if the first part of your logo filename is really unique like unsportingly.unique.emxlogox.0FAE7E6.png so you don't have to do millions of Google Search API queries - just search on the unique first part of the filename - and look at the hashes after you get the hits.
You store the links where their copy of the logo appeared in your db to add to your dossier of where on the net they are active and have helped you.
Yes, it's slow and burdensome, but in these days when we say we want to develop a 'relationship' with our email list, it's what you have to do to give individual treatment; identify and reward your friends. And yes, you end up with millions of those hashed filename images in one directory, but storage is cheap and it's worth it to really have that relationship with your peeps.
You can't add javascript to your emails.
The only solution would be to have only a link in the email, and the message on the server, Then you'd able to know that the message itself has been viewed.
Embedding a user specific image (1px blank might be good) in the email and record whether it is hot or not is a fair solution. But the problem Gmail like client block external images by default.
Please refer RFC-3798 for more details about MDN.
As the last post was awhile back, I am uncertain as to whether this method still works.
I tested this method on a server running PHP 5.4.30, and it does not seem to output an image.
This is some very simple code:
<img src="http://theservername.com/myaccount_email_read_offline.php">
Note that I removed the querystring and any additional code from this image.
Opening up that separate page, myaccount_email_read_offline.php did display the image.
However, trying to include the image by including a PHP file in its place did not work.
As some of the other answers have mentioned, it is possible to detect when a recipient has opened a message, if the message contains a remotely hosted image (and the recipient's mail client is set to open remotely hosted images).
UltraSMTP is an outgoing SMTP mail server that inserts a remotely hosted image in each outgoing message sent through the server, for this purpose.
See https://www.ultrasmtp.com/kb/developers.php for sample code for sending mail through UltraSMTP from a PHP script (using PHPMailer).
Related
I want download a report that I'm receiving every day on my inbox.
This email contains a link to a platform (where I have to be logged-in on the platform to open the link correctly, otherwise I will be redirected to login page) and finally there is another link that downloads the report to my computer.
My question is: It's possible to make a PHP script that can do this automatically?. All the process to read the email and identify the link it's easy, I want some guidelines to continue working.
Thanks!
This may be harder than you anticipate and PHP may not be the best language to achieve what you are after as it can not run on top of Outlook or any other desktop based email client. To do this you would have to run the PHP code from the command line, and have it set to regularly intercept all your emails and check to see if the email is from a specific user, and if it is parse the email for the two necessary links. Once you have the links you can have the code establish a cURL connection to the login form and pass the username and password, ensuring to pass any cookies defined from the authenticated session, and then establish a new cURL link to the download link to download the file to the local file system, after which you can send a new email to yourself attaching the file as a native attachment, dependant on file size.
Information on sending cookies with cURL can be found at How can I send cookies using PHP curl in addition to CURLOPT_COOKIEFILE?
The net result though is that this would have to run in the background continuously and would have to be set to regularly connect to your email server and check all emails for the existence of emails from the automated email sender.
An easier solution would be to find out if the automated tool can be setup to simply send the file as an email attachment so that you don't have to run the excess code. In addition any time the initial email structure changes or the download or login links change you would have to update the code to deal with the associated changes.
Main point is that PHP isn't the most ideal solution for what you are trying to do and what you are trying to do, in any language, is going to be a complex task to achieve.
When you already have the email link you could login to the platform using a curl request and afterwards make the same call again. the second time you'd be logged in and curl would download your report.
You could use the cURL library.
How does your platform identifies you ? If you can use cookies, look for
CURLOPT_COOKIE
curl_setopt($ch, CURLOPT_COOKIE, session_name() . '=' . session_id());
i have the a similar issue, i want to open on googlesheets a series of reports from my email, managed to do it when its attached evenif is a zip, but when its only a link o cannot do it, heres the script i use, maybe someone could upgraded to open links and import the csv
function importCSV() {
// Change the report name Report
var threads = GmailApp.search("subject:XXXXXX has:attachment from:XXXXX#google.com newer_than:1d");
var message = threads[0].getMessages()[threads[0].getMessages().length-1];
var allAttachment = message.getAttachments();
var attachment = allAttachment[0];
var contentType = attachment.getContentType();
var name = attachment.getName();
if (attachment.getContentType() === "text/csv") {
// Change the sheet name, where you want the data to appear
var sheetActive = SpreadsheetApp.openById("1slVepI8s2Ekdiha0u4NpqFLZ4NnJrhyc8in9hYNzJA0");
var sheet = sheetActive.getSheetByName("Youtube");
var csvData = Utilities.parseCsv(attachment.getDataAsString(), ",");
// This clears the document from previous data
sheet.clearContents().clearFormats();
// Import the CSV file to the spreadsheet
sheet.getRange(1, 1, csvData.length, csvData[0].length).setValues(csvData);
}
else if (attachment.getContentType() === "application/zip") {
attachment.setContentTypeFromExtension();
// Unzip Attachment Change the sheet name, where you want the data to appear
var sheetActive = SpreadsheetApp.openById("1slVepI8s2Ekdiha0u4NpqFLZ4NnJrhyc8in9hYNzJA0");
var sheet = sheetActive.getSheetByName("Youtube");
try {
var unzip = Utilities.unzip(attachment)[0];
var csv = unzip.getDataAsString();
var csvData2 = Utilities.parseCsv(csv, ",");
// This clears the document from previous data
sheet.clearContents().clearFormats();
// Import the CSV file to the spreadsheet
sheet.getRange(1, 1, csvData2.length, csvData2[0].length).setValues(csvData2);
} catch (e) {
// Logs an ERROR message.
console.error('myFunction() yielded an error: ' + e);
}
}}
I'm not sure where to begin with this task, so I'm looking for an answer on just the idea of how to go about doing this.
When a new user creates an account on my Codeigniter site I send him/her an email about signing up (very typical). Here is how I'm sending the email...
...
$subject = 'Welcome to __________, ' . $firstName . '!';
$emailData = array(
'name' => $name,
'blah' => $blah,
'blah' => $blah,
// etc.
);
$html_email = $this->load->view('emails/signup_html_view', $emailData, true);
$text_email = $this->load->view('emails/signup_text_view', $emailData, true);
$this->email->from('team#_________.com', '________ Team');
$this->email->to($to);
$this->email->subject($subject);
$this->email->message($html_email);
$this->email->set_alt_message($text_email);
$this->email->send();
...
As you can see, I'm passing data to those views to send the email. In the email view, at the top, I have a link that says "Problem viewing email? Click here to view it online.". That is common practice for emails on newsletters, signups emails, etc. so that the user can view the email online if it renders weird or something goes wrong.
Where I'm getting lost is how do I generate that unique "...view it online." link so that when the user clicks it, they see an online version of the email and the online version still has all the data still passed to it? Do I need to create a separate controller or what is the best way to handle that? How do I generate that unique link?
#zach,
yes, what you do is:
1) create a separate controller that can display this email, just like you were making a page
2) I'm assuming the user is already created in the db, but is not yet activated or taken steps to be able to login. So, backing up a bit, when you make your user record, also create a random hashtag & store that.
Now, in the email link, set it to www.mysite.com/welcome/hashtag
This way you are allowing them to get a unique record without using an id that they could just use to go look at everyone else
This welcome page, of course, doesn't require them to be logged in. Probably you give them a submit (maybe after they fill out some more info) that will then activate their account
Hope that was close enough to what you were asking to get you through
Hoping some of you out there are great with php!
Basically the guy who made this is MIA so I can't ask him what I need to do to fix the problem we are having.
Background:
We are a locksmith company that uses a custom web app to inform our locksmiths on the road when they have a new job. This web app also does a few extra things like providing gps location, time taken at the job and the ability to have save signature from the client upon work completion.
Problem:
The app works by picking up an email sent from our account management application called E3, the email (example: http://cl.ly/image/2E433O330T0N) is read by this web app, parsed into both an email and a web page and sent to the locksmith to view his new job. When the locksmith arrives at the web page on his phone (example: http://cl.ly/image/0P1I0R0h0O3K), he can see the job details including the Name, address and contact details for the client. The problem is though, because Job Notes isn't assigned a heading in the original email the code has to work out where Job Notes is located, this is the part that has the problem as the web app is no longer showing the data in Job Notes. Job Notes is important because it tells the locksmith what he needs to fix. This worked previously but has now just stopped working and we aren't sure why.
How the data is transferred to the web app is very interesting, instead of having a database to store data to, it is put in the address bar and then the webpage interprets the code and formats it into the page.
For example, this is how the current link looks (data taken out, replaced with xxxxxxx):
http://www.xxxxxxx.com/apps/xxxxxx/on-my-way?client=xxxxxx&company=xxxxxx&mobile=xxxxxxx&phone=xxxxxxx&contact=xxxxxxxx&addressData=Array&addressIndex=3&streetAddress=xxxxxxxxx&addressLocality=xxxxxxxx&postcode=xxxxxxx&city=xxxxxxx&clientEmail=&jobDate=11/22/2012&jobTime=1:30:00%20PM&jobID=xxxxxx&jobAMPM=PM&adminEmail=xxxxxxx&noreplyEmail=xxxxxxxxxx&companyPhone=xxxxxxxx&staffEmail=xxxxxxxx&staffName=xxxxxxx&staffPhone=xxxxxxxx
Previously, when working, this link had a jobNotes field added:
http://www.xxxxxxxx.com/apps/xxxxxxxx/on-my-way?client=xxxxxxxx&company=xxxxxxxx&mobile=xxxxxxxx&phone=&contact=xxxxxxxx&addressData=Array&addressIndex=4&streetAddress=xxxxxxxx&addressLocality=xxxxxxxx&postcode=xxxxxxxx&city=xxxxxxxx&clientEmail=xxxxxxxx&jobNotes=Quote%20on%20installing%20new%20keying%20system%0A%0AAlso%20would%20like%20a%20Quote%20on%20Install%20CCTV%0A%0ASub%20Total%3A%202%2C236.36%0AGST%3A%20223.64%0ATotal%3A%202%2C460.00%0A%0AMISC&*jobDate=11/19/2012*&jobTime=2:00:00%20PM&jobID=xxxxxxxx&jobAMPM=PM&adminEmail=xxxxxxxx&noreplyEmail=xxxxxxxx&companyPhone=xxxxxxxx&staffEmail=xxxxxxxx&staffName=xxxxxxxx&staffPhone=xxxxxxxx
The code:
This is an extract from e3-parser.php, the main file that translates the data from the e3 email to the web app.
// Job notes
if ($this->clientEmail) {
// REMOVED NOW THAT EMAIL IS BEING PUT ON THIRD LINE OF ADDRESS
// // If customer email present grab everything after it save it as job notes
// preg_match("/$this->clientEmail[^-]+/",$e3Output,$matches);
// $result = implode("",$matches);
// $notes = trim(str_replace($this->clientEmail,'',$result));
// $this->jobNotes = rawurlencode($notes);
// } else {
// Fall back to grabbing everything after the time
preg_match("/AM[^-]+/",$e3Output,$matchesAM);
preg_match("/PM[^-]+/",$e3Output,$matchesPM);
$resultAM = implode("",$matchesAM);
$resultPM = implode("",$matchesPM);
$notes = trim(str_replace('AM','',$resultAM) . str_replace('PM','',$resultPM));
$this->jobNotes = rawurlencode($notes);
}
Question here is, does it successfully grab the data listed after the Required Time field? (example email that it's reading from: http://cl.ly/image/2E433O330T0N)
Here is the code that places the parsed data into the web page:
// Create job link
$url = $e3->create_job_url('http://www.prvgroup.com.au/apps/jobbook/on-my-way?');
$linkName = "View job details";
$href = '<a class="btn btn-small" href="' . $url . '&staffEmail=' . $staff- >staffEmail . '&staffName=' . $staff->staffName . '&staffPhone=' . $staff->staffPhone . '">' . $linkName . '</a>';
This is sent to the locksmith via email informing him of his new job on the clickable link "View job details". The link is impregnated with the data needed. However from the looks of it the data for jobNotes isn't there. My backups of this code display the exact same thing here when the code was displaying jobNotes so I'm not exactly sure how it is putting that field in.
If you got this far, well done! I hope I was clear enough with what the issue is but if you need anymore clarification, just ask!
Cheers,
Marc
After looking through your code you are only running the preg_match if there is a clientEmail. From the sample emails above it does not look like you are ever executing this code because there is no client email or it is not found using the preg_match. The specific location to look into is on line 113 of the e3-parser.php file. You will see this:
if($this->clientEmail)
{
//matching code here.
}
on line 109 and 110 you are looking for an email address and either not finding one or it is looking in the wrong location. At any rate, you should execute this code regardless of whether there is an email address or not. The notes must be set for later use, right now nothing is being set. Removing this if statement should resolve your issue.
I'm using the Zend_Mail_Message class to display emails inside of my PHP app, and am able to output the subject, content, date and even the NAME of the sender (using $message->from) but I can't figure out how to get the email address of the person who sent the message. The documentation is no help and googling finds a million results for how to send messages with Zend, but nothing about getting the address that sent the message.
EDIT:
This is how I ended up doing it. After some more digging, I found the sender's email in a field called 'return-path'. Unfortunately, this field has a dash in the name (WTF??) so to access it, I had to do this:
$return_path = 'return-path';
$message->reply_to = $zendMessage->$return_path;
Using the return-path caused some problems with some emails, specifically messages from no-reply accounts (mail-noreply#gmail.com, member#linkedin.com etc). These addresses would end up looking something like this:
m-9xpfkzulthmad8z9lls0s6ehupvordjdcor30geppm12kbvyropj1zs5#bounce.linkedin.com
...which obviously doesn't work for display in a 'from' field on the front-end. Email clients like Apple Mail and Gmail show mail-noreply#gmail.com or member#linkedin.com, so that's what I was going for too.
Anyways, after some more research, I discovered that the 'from' field in a Zend Mail Message object always looks something like this:
"user account name" <user#email.com>
The part in < > is what I was after, but simply doing $from = $zend_message->from only gave me the user's account name (hence my original question). After some more playing around, this is how I finally got it working:
$from = $zendMessage->from;
$start = strpos($from, '<');
$email = substr($from, $start, -1);
$result = str_replace('<', '', $email);
Hopefully this will save someone some frustration. If anyone knows of a simpler way of doing this, please let me know.
This works well..
$senderMailAddress = null;
foreach ( $message->getHeader('from')->getAddressList() as $address ) {
if ( $senderMailAddress === null) {
$senderMailAddress = $address->getEmail();
}
}
The main problem here is that many email programs, relay agents and virus scanner along the way do funny stuff to an actually simple and well defined email standard.
Zend_Mail_Message extends to Zend_Mail_Part which has a method called getHeaders(). This will have all the data from an email stored in the head versus the body which is accessed with getContent() and the actual email message.
With this method you'll get an array of all the key/value pairs in the header and while developing you should be able to determine which header field you will actually want. Once you know that you can then get the actual field with getHeader('field_name') or with its actual name directly.
However, if you have to many different email senders you may want to stick with the complete header array though and evaluate multiple fields for the best result like if there's an "reply-to" address. Again there are many uncertainties because the standard isn't always obeyed.
This is my current code:
and I want to add a number of tables to change the design of the email, I am very new to PHP and ZEND any help would be great thanks.
As Mike Brant said, you can create your HTML then copy in inline. However you will then need to ensure that the email is sent with the proper mime-type so that the user's email reader knows to render as HTML and not as plain text. It isn't that hard, but I found that the PEAR mail and mail_mime libraries really make it even easier and more obvious what's being done. There are also some 3rd party email apis, for example I've had good success on one project using http://swiftmailer.org/
The best way to start is to just layout your email in HTML the way you want it and then just copy into your HEREDOC section and replace the content with the variables.
Create one (zend)layout for your e-mails like you do it for your website. Best with html 4.0 doctype. Avoid CSS. Most E-Mail Clients cannot render it correctly. If you have to use CSS, embed it into style-tags (no external content) and embed the style-Tag into the body. (most web-mailers are dropping the head-section).
Now create views for every mail-type you want to send (e.g.: registration, pw-lost,...)
assign the variables to the view and render it into the layout. Render the Layout into Zend-Email Object.
If you want to manage the content, subject, sender,... over an administration-area, just create a table with the following colums:
type (can be registration, pw-Lost...)
Subject
From
To (for mails which are adressed to the admin e.g.: when users post comments)
CC
Bcc
Html-Text (the Text of the e-Mail with Place-Holders for personalzation)
Text (optional plain text containing Place-Holders) you can pack this text additionaly to you html-Mail or just send html or Text Depending on the user settings.
Some extra-colums for attachments (optional)
Now you can adminster the different Mails and drop your views (not the layout).
At least create a mail-class which you can access in that way:
$mail = new My_Mail(My_Mail::PW_LOST);
$mail->bind($userData); // will replace the placeholders in the text
$mail->addTo(...);
$mail->send(); // will replace the placeholders in the text, renders the layout, Sends the mail.
Code-Sample:
I can provide code samples on saturday if you are interested
You can use the Zend_Mail class (Zend/Mail.php) to send emails. The details are in the code sample below:
$mail = new Zend_Mail();
$mail->setBodyText($bodyText);
$mail->setBodyHtml($bodyHtml);
$mail->setFrom($senderAddress, $senderLabel);
$mail->addTo($recipientAddress, $recipientLabel);
$mail->setSubject($subject);
$mail->send();
A question you might have is how the email (text and html) contents are assigned to $bodyText and $bodyHtml. You can create a couple of phtml files one for html content and the other for text. See the code below on how to achieve this:
$this->view->fullname = "John Abc";
$this->view->emaildata = $data //Possibly an array of data from the db
$bodyText = $this->view->render('emails/htmlemail.phtml')
$bodyHtml = $this->view->render('emails/textemail.phtml')
Note: This snippet should be above the previous one.
Hope this answers your questions. Happy coding :)