Rich sites such as facebook send you an email for every event that takes place, notification, friend request and so on, I would like to know how costly is it for the web server to perform this action? that also 100s of time a day for active and popular users.
Usually the site do not send emails itself. It just redirects email to server MTA, which then saves it in it's queue and sends when it thinks best.
To answer your question we need the definition of "costly". To send an email you typically need to execute some DNS queries, connect to remote server, exchange data with it. Is it costly in your opinion?
It's a good idea group destinatarys by BCC header to reduce the email server calls, if you is using an external SMTP that it's the slower phase.
PHP only uses one thread that means that next email will be send once the current mail was sent to the SMTP server. In Java for example you can send emails in a pool of threads at same time, and course, it's faster.
Related
I have special e-mail accounts on my web server (#mydomain.com). I want to run a php script automatically when one of these accounts get a new e-mail. For example: when info#mydomain.com address receives a mail, I want to run "receivedMail.php" file and read this new e-mail. I don't know where I will start or how can I do this.
You're wanting to pipe email received for a specific email address to a PHP script.
If your webhost has cPanel, this makes it very easy to setup. See:
http://kb.siteground.com/how_to_pipe_an_email_to_a_php_script/
Alternatively, if you don't have cPanel but have Exim mailserver, this will guide you on how to do this:
http://www.phpshare.org/articles/Piping-Incoming-Mail-with-PHP
Hope this helps!
You have to create a cron job calling your php file every 1 minute for exemple.
The script have to the derver and read the email.
This has nothing to do with web servers directly, Since web servers do not receive emails. So no .htaccess style files come into play. The email is received by a mail server, so that is where you have to get active. Two strategies are possible:
you use the possibilities to trigger an action as offered by your
mail server (typically the smtp server you operate). That obviously
depends on which mail server you operate, different software offers
different features.
you poll those email accounts on a regular base, using a standard protocol like POP3 or IMAP4. You can do this using any suitable client. When a new message is found whilst polling the account, then you trigger the action you wish.
Option 2. is probably easier to start with. So give it a try: create a php file which polls your email server. You can use the imap php extion for this, it supports all important email protocols. The extensions allows to easily detect and retrieve new messages. For each such message you can implement whatever action you wish. All that is left is to run this script on a regular base, say every 3 minutes, which is typically done using a cron system. There are many examples for this out there on google...
Have fun!
I have developed a CRM that is used with a marketing website similar to manta.com. The CRM has a built-in email client. Basically it matches names and emails to addresses on file, and if the email is from a customer it loads their account information next to the email.
The entire system works, but is in some cases slow. Because each "region" of the country is managed by a different company, the software connects to several different mail servers, all of which behave differently.
In some cases (mostly with godaddy servers) it takes a very long time to send an email. It also takes a long time to load the inbox if they have a lot of messages (500+), even if it is paged.
I am using pear Mail::Factory smtp to send, and the built in php imap functions to receive.
I am thinking for outgoing messages I will just store the emails into a db and then have a cron script send it out, then they can send their email and move on right away.
Does anyone have any ideas/concepts for handling large inboxes via IMAP and php? I will have no control over the mail servers themselves, but have full control over the server that the CRM is on.
I am not looking for code, just concepts if you have them.
It is Linux (ubuntu), apache, mysql, php. I can use Zend if needed.
It looks like a combination of caching the emails and using the imap_fetch_overview function which omits the body of the email. This seems to eliminate any issues with the lag. I can also use it to page the results so I am only loading a small number (25-50) at a time. Thanks for the help.
I am developing a social networking site. It has functionality like user registration, people exchanging messages and sending email notifications for people's actions (and many more).
Currently I use PHP's mail function to send mails and it is working fine. I already set up a VPS and hosted the application.
My question may be a dumb question. Do Facebook and other social networking sites use SMTP servers to send the notifications or only just any kind of PHP mail function?
I read somewhere that using PHP's mail, there is a chance of mail going to SPAM folder. They advised using a certified SMTP server.
So, if I have to use an SMTP server:
1) Do I have to purchase a certified SMTP server separately? Or can this be hosted on same VPS whatever I have. If so, what server software will be good for this?
2) Are there settings I have to do in SMTP servers like send unlimited messages, because we don't know how many people exchange emails in a minute, and that is totally random.
To start: you are definitely going to have to use an SMTP server to send the emails from PHP. You can't simply throw your emails at the mail() function and expect it to work. You have to connect it to an SMTP server that does all of the dirty work.
However, if it's not your domain, I would suggest you don't do it. If you have the time to learn the ins and outs of email delivery and want to set up and maintain an SMTP server, by all means, go ahead.
If you'd rather focus on building your app and not worry about your emails getting delivered, I'd suggest an email delivery service. Here's a good list of services to check out:
PostageApp
Sendgrid
Postmark
Mailjet
And there are plenty more out there. All of them have a free option for you to play around with, so just look for the one that fits your needs and requirements.
(FULL DISCLOSURE: I am the Product Manager of PostageApp. Happy to answer any questions you might have about sending email from your app, though!)
The issue here is not really with the mail() function in itself, but in how you construct the emails. Messages can be treated as spam for a million and one reasons, but it is generally accepted that if you use one of the tried and tested mailer libraries, like Swiftmailer or PHPMailer (both free) there is marginally less chance of your messages being treated as spam.
Whether your messages get treated as spam is far more about how you construct your messages than how you send them. Another major factor is if your server sends thousands and thousands of emails all the time, so another hint is to be sparing with the emails you send out - only send them when you actually need to.
If you really want to know the answer to this question, you should do some reading on exactly how the modern email system works. Being able to build and send good emails is all about knowing how to work the system. Start here.
i need to send bulk mail in my php application, but its outgoing limit was 500, if i purchase VPS server for sending email if it grows more than 1000+ gmail /hotmail will mark me as a spam , so what is the solution for this issue?
{ purchasing api from mass providers is not under my budget }
If you think your mail is not spam and your mail server is not setup as a relay to others, then it is ok to go with a VPS server for the purpose.
In my case, I keep sending alerts to my customers on different conditions. The emails may amount to about 10000 a day. But I hear that these are blocked only in rare occasions and we ask the customers to add our from email to their address books and it becomes good after that.
If your mail is not SPAM then you should be be able to deliver it, with some effort. Read for example Gmail Bulk Senders Guidelines.
One consideration is that you should not start with sending thousands of mails to gmail or any other mail provider. If their system does not know your server (specifically the IP address of your SMTP server), then it will block you. Start sending a few mails per day, and gradually increase the count.
I think VPS is only usable if you get your own dedicated IP address. Otherwise I would rent a dedicated server.
I can suggest you an idea,which might sound WIERD !!!! and might lead you to pull hairs.
Search for peter bromberg article in egghead cafe on Asynchronous Mail sending technique. Search on google if you can send messages from multiple account via single app. For example if your target for the day is 10000 mails, and per day limit for any common email id (or free version or lite version of any bulk mailing) is say 500 then create an array of your email and assign them mail sending responsibility as per their limits. try to achieve this via your programming skills.
This is the only way i can suggest you in a very cost effective manner. But again you need minimum of 10-15 email ids for it, which is a biggest drawback of these approach.And you might need to create more 10-15 emails, if the earlier ones get blocked by your Service Provider or receivers SP.
Lets take a look at the following scenario:
I have a websitesite, site.com. One customer support tech guy has an email account on it: techguy#site.com. Customers send messages to that email, tech guy replies via that email. They are both using desktop email clients (thunderbird, outlook...).
What I know is: using php to read incoming mail from customers
What I want to know is: how to use php to read outgoing mail that the tech guy is sending from his client via smtp, imap..
This would be used for archiving conversations between techs and customers without forcing them to use some php app on the site to send emails (I want them to use desktop clients).
I dont know much about email protocols, but I have plenty of experience in php. Im guessing that the email daemon could be setup to call a php script every time it recieves an outgoing email or something like that. Is there any way that this can be done?
The way how some products on the market are doing it is by requiring the user to install a plugin on his/her email client. Using this method doesn't matter what smtp server is used, the mails will be logged using the plugin.
Another way(this is just an idea) is to "force" the tech guy to use your smtp server so you can access the logs and see who sent mails and who is the receiver(accessing the logs using php)
It would be much easier to have a separate email address for logging purposes and simply keep it in the cc or bcc field for all communication between customer support and clients.
since you can have php interpret the emails, the best thing to do is have a dedicated email address that gets piped to a script (i know this is easy to set up cpanel)
you have the client email support#domain.com which gets piped to the script - do what you want with it there.
then you have the script email back out to bob#domain.com with a from address as support-reply#domain.com - which is also piped to a script
when he replies to that, it goes to support-reply#domain.com which goes to a script, which in turn you would process, then forward back out to the client#google.com with a return address of support#domain.com
i think amazon uses a similar technique so that people can email each other back and forth, but they create coded email addresses and have a database to keep track of who they are going to and coming from.