I want to create a system, where an email is sent to me using smtp and i perform all the validation and some manipulations in HTML. and then send it using SMTP.
Currently i have some applications which are using SMTP as email sender, i want to create a simple layer in between them so that all the emails are sent from this filter, so that i can edit HTML source code and add some tracking links or check weather to send this email or not, depending on the spam and other filters.
This is a great PHP framework for sending emails, its supposedly very difficult to send emails from within PHP its self using the mail() function.
Are you trying to import an email sent from a specific address to you, extract data from that email and then forward the information on? Can we get an example of the email you are trying to extract/manipulate? I feel some more information on the task at hand would make this easier!
EDIT
So if understand correctly you want to program an application that all your other applications interface with and send emails from this new application?
If so there is lots of ways you could do this, I'm not aware of any github solutions (Correct me if I'm wrong) & I don't think any sort of SMTP service offers what you are asking (HTML changing being the big problem I'd imagine).
So what you could do is write an application with an API (referring which application sent the request, desired recipient, email template to use ETC) with all of your different settings/spam filter restrictions stored in database. You could then keep your emails all in a folder within the new application and when you amend them they get sent out.
Another solution would be to create a folder that contained all of the email templates, then create system links (securing X,Y&Z attack vectors) to your different PHP projects which depend on these email templates and do per application filtering (Spam/HTML Changes).
Related
Like Wordpress and Blogger have. For example, I send an email to something_blog_post#myblog.com and the email that I sent would be transformed in a post on my blog.
There are services like mailgun that make this fairly easy to do since they convert inbound email into API calls.
The alternative is to find a way to poll IMAP with PHP, then parse the messages. This is probably a whole lot harder.
There are several solutions to this problem:
Firstly, you can setup a system to poll an existing IMAP or POP3 system and return the result.
You can setup an email server which will call a script itself upon receiving an email.
You can use a third party provider (such as CloudMailin or MailGun).
I wrote a blog post a little while back outlining some of these options for Rails applications but they all apply directly to PHP too.
We are developing a email web site.but we are facing problem in receiving and validating the mail.i have the following doubts.can you please help me in clarifying these???
one more important thing is we are not using squrrelmail, qmail etc.
how do we receive emails for users in email web site?
do we save all the received emails in admin's mail box or in database as per the username
(my idea on email web site is,all the incoming mail are stored in admin's mail box and after the email mail is stored in database,and then the mail deleted in admin's mail box.Is it correct.if not how to store the emails in database directly in web site)
what is the technique behind the receiving mail???i think there are various techniques like email piping etc.
is there any special process of creating users for email web site,i mean do we need to create mailbox(i think mail account) for each user at the time of registration.if we need to create mail box for user,can we create it with imap_createmailbox() function.
are the users gmail,yahoomail etc are accessig database or their mail accounts at the time their login??
can we do all these things with imap functions in php??
There are many different solutions to this problem, polling existing servers, adding scripts to run when a message is received or using a gateway like CloudMailin. I wrote a blog post relating to this (it's for rails but almost all applies to php too).
The other problems almost all span from how you setup the first thing. In many cases you could just log the emails directly to your database and retrive them based on the recipient address. I think you need to explain exactly what you want to do with the email? Are you just providing email hosting for your users or are you providing an additional service? If you're just providing hosting then there are simpler approaches available.
Client asked this morning if we can provide a subscription service whereby:
Mail arives to a specific address on a cloud mail server with no procmail/maildrop possibilities
Cron runs Perl or PHP script on another server which checks for new mail and based on address mail purports to be from, does a subscriber look up, and forwards the email with any attachments to all subscribers along with an added unsubscribe link
Script deletes forwarded email
Mail server will have both IMAP and POP access, apparently.
// EDIT
Note that mail will be from 220+ governmental agencies/organizations. Users will use interface to specify which organizations they wish to receive forwards from. In order to run like a traditional mailing list we'd have to set up 200 mailing lists and then make an interface to handle subscriptions. The proposed interface will allow 1 - 200 subscriptions with a single opt-in confirmation email and a single opt-out interface.
// END EDIT
Client has been warned that header spoofing is child's play and that viral attachments are a serious concern and is willing to proceed nonetheless.
So, with the caveat that this is NOT an idea that I endorse what libraries have you used to accomplish this sort of task?
You do not mention what kind of mail server you are dealing with. Perl has Net::IMAP::Client and Net::POP3 to handle fetching mail.
For sending email using an SMTP server, there is Email::Sender or Net::SMTP or Net::SMTP::SSL.
At a minimum, you'll need an email account which you can use to send emails (this might be the original account that receives the messages).
In between fetching and sending, you can check for spam using Spam Assassin and for viruses using ClamAV.
I don't know why the original messages need to be deleted, but at the very least, I would log every single step in detail.
What you're describing is a mailing list. If at all possible, you should look into using one of the several existing software packages designed for managing such lists, such as majordomo, ezmlm or mailman, rather than trying to roll your own.
I have a PHP website that send a validation code when a new account is created.
My problem is since few months, a lot of those email goes in the spam folder.
I thought of a solution that is to use an "external service" to send my email instead of simply sending it via the mail function in PHP.
Question : 1) What external service should I use (I guess it would requires to have an API)?
Try using your ISP's or company's server as a relay. Use a sending address which exists, so that validation can be done on it, and bounces sent back to it. You may want to setup a separate domain for verification such as verification.example.com. You could then send the validation message from application#verification.example.com. Replace application and example as appropriate.
You may also want to look at https://serverfault.com/questions/241189/email-delivery-management-grievances#241260.
Have a look at this documentation from Google. It involves your network support including reverse lookup and Domain keys to be present. I think most of the email servers would have similar requisites.
Many times, when using the builtin mail function, the configuration isn't set up to help prevent this from happening. The reason is the Received header is set to an internal IP address, like 192.168.x.x which is used as an indicator to most spam filters. You may want to try finding a simple SMTP class that connects remotely so the headers get set properly.
Well, I'm trying to create a newsletter, that will send emails to users in a database. The newsletter itself would draw "events" and other activities from a database. Whats the best way to take that list, and put them in an email? I was thinking about putting them into an html page, then sending an html email, but not all emails support html(like school email). What would your guys recommend? Could you point me to some good resources?
Also, this is for a school project, so I cant use any open source type stuff, unfortunately :(
You are correct in your assumption that if you are creating html newsletters, you will also have to do a text based version for clients that don't support html or ones that ask to have e-mail be sent only in text. You will need to make sure your code sends both versions to recipients. You could also ask the recipients for their preference and send them the specific version that they requested.
For html e-mail it is highly recommended to read the following two articles by CampaignMonitor (they specialize in e-mail marketing sofware):
HTML E-mail Design Guidelines
Guide to CSS support in email
clients
Note that I am assuming you are asking for help with the actual construction of the html for the email not the code needed to create and send the newsletter.
Good luck with your project.
==== UPDATE ====
So it seems that you actually need help in developing this project. Since this is a homework, I will provide some general advice that should steer you in the correct direction and get you started on the project. Then, if you have any specific problems with your code, you can ask about them on Stackoverflow.
There is really two things that need to be done here:
In PHP, dynamically contruct a variable that contains the html or text versions of the e-mail that needs to be sent.
Loop through your contact list and e-mail the contents of that variable.
Sending E-mail
I will start with the sending e-mail portion, because the links provide bellow also show you how to construct the message. Also, in your comment you said you already know how to contruct an html from a database. The following links show you two ways to send e-mail. You can either use the Mail function that comes with PHP or download the PEAR_Mail package. If you are allowed to use additional libraries and want to send html e-mail, I would recommend using the PEAR_Mail, because it makes things much easier if you want to send a both an html and text version of an e-mail together.
Note: To send an e-mail you will need to use some sort of mail server. If you are using Windows, you can install the SMTP service that comes with IIS or you can use an external smtp service such as google to send your e-mails.
http://www.w3schools.com/php/php_ref_mail.asp
http://us2.php.net/manual/en/function.mail.php
http://www.webcheatsheet.com/php/send_email_text_html_attachment.php
http://pear.php.net/manual/en/package.mail.mail.php
http://pear.php.net/package/Mail_Mime/docs
Construct E-mail
The complexity here will depend on whether you just want a plain text e-mail or html. For either case you will need to read the event data from your database and add it to the message that you want to send.
Some Seudocode:
Loop through datarows
message = DataRow[EventDate] + " " + DataRow[EventName] + "\n"
Loop through recipients
mail message
Hopefully this gives you a start. I would recommend getting php to send out an e-mail of a static html or text first. Once you have that code working you can start working on adding the functionality of reading event info from a database and sending it out.
Hope this helps.