sending a lot of email in newsletter module - php

i am writing a newsletter module in php/mysql.
how can i send email to site subscriptors that doesn't cause my mail server get blocked ? i mean it doesn't treat as a spam sender?

The full answer to this question is really outside of the scope of this site, as much of it will involve administrative tasks with the domain and server(s) involved.
But the short answer is: Don't do this! You will just end up getting your server's IP blacklisted, making even low-volume e-mail sending worthless from that server.
You should look at other options; an RSS feed, a third-party, well-run mailing service (like Constant Contact), or something else.

Use Cron job to do this and send mails in small chunks with a time difference.

There are several rules that you need to follow if you want to send out emails from your site and have then not being flagged as spam:
Start with the most obvious: check to make sure IP address of your server is not on any spam black lists. Try this site: link text
By default all emails sent from a website hosted on Apache server are send from the user Apache server runs under, usually 'nobody'. This is a red flag for spam filters, so you have to modify the value of 'return-path' header which is not always allowed by email server. If you can't modify return-path, then you need to start apache as another user, create a new account for your apache server, name it anything you like as long as it's not 'nobody' and then configure apache server to run as this new user
Very important to have reverse DNS entry for the IP address you use for sending out emails. That reverse DNS entry must point to same domain name that points to this IP address. This is actually the most important thing to do. Since only a webhost can add reverse DNS entry, you should ask your host to do this for you.
Other smaller steps that can help is to configure an appropriate spf entry in your DNS server and another one is to use digital signature to sign all your outgoing messages. I used to use a program called dksign for this, it's probably not the most up-to date program now, so do your research and find the best way to sign your messages.
Use common sense when creating subject lines. If you say "free discount offer" in the subject line or something similar or "get viagra", your message will probably be flagged as spam no matter what.

Related

How can one resend a received email as totally NEW email? So no forwarding or re-directs

This has been a massive headache. We use Ning as a our platform for an arts event project. We want to ask our audience to upload photos to our website via an email address. The only issue is that Ning only will give us ridiculous email addresses for this purpose... such as photos34628234896#ourwebsite.com That hardly sticks in the mind!
So I thought, lets just forward emails from an easy to remember email address to the Ning's crazy one... BUT Ning doesn't allow any emails to upload photos if they are detected as being forwarded or redirected. I guess that detection is done through the email header.
So that is why I need a way to redirect an email to another address without that being reflected in the header info in the email. I thought perhaps Outlook receiving the emails from the easy to remember email address, then somehow resending them with a fresh clean header may be the answer? I can code in PHP, and run a home headerless ubuntu server on a domestic internet connection too if that may provide a better answer?
Any thoughts how I could achieve this goal?
If you can forward the email to your server you can have it piped to PHP which can then resend the email for you with whatever email address you wish to be displayed. Just make sure you have things like DomainKeys and SPF records set up for that server or else your chances of the mail being seen as spam will increase.
If you are using an Exchange server, you can use Transport rules to redirect the message, which will pass most forwarding checks. If it does indeed change the headers or something else, you can use the same ruleset to remove or modify them. Most MTAs(Mail Transport) will allow the same sort of functions, but it really depends on which one you use. Postfix is quite flexible.
The changes will be made in
Exchange Management Console
Origanization Configuration
Hub Transport
Transport Rules
Also, and maybe easier, you could simply try to add a secondary delivery address, in the mail flow settings for the fictional user you assign to receive the emails. This would be done in the user properties. Server level forwarding amy not trigger the forwarding blocks that you are encountering, as client forwarding does not work the in entirely the same way. Many clients send the email again, but the server redirects it.
Exchange Management Console
Recipient Configuration
Mailbox
Properties, Mail Flow Settings.
You would enable forwarding in Delivery Options.
Sorry, just noticed that you are using ubuntu, you can simply have postfix redirect the email for you, you will use Postfix Virtual Alias Maps...
Here is a link that describes it perfectly...
http://www.cyberciti.biz/faq/linux-unix-bsd-postfix-forward-email-to-another-account/

Automatically Create Email

First of, let me just say that I know similar questions have been asked
Here
and here
But, there are problems with both questions. Question one has only one answer (which isn't helpful) and question two needs to work with Google Enterprise.
I have a LAMP stack hosted on Linode which hosts multiple sites each with a separate file in the sites-available folder. I have a specific domain which we will call myawesomedomain.com. Now, myawesomedomain.com has nothing in it right now and will not have any proper, full-fledged site. Only a simple form. The fields will consist of:
Username
Email Address
Password
Here's what I want. Whenever a user signs up, an email is automatically created with the username username#myawesomedomain.com. From that point on, whenever email is sent to username#myawesomedomain.com, the email is automatically forwarded to the email the user signed up with so that the email is never stored on my server (and therefore does not take up space).
So, my essential questions are:
How do I automatically create email addresses from PHP
How can I have the emails automatically forwarded to another email address in a MySQL database and not stored on my server.
What mail server should I be using and how should I set it up so it doesn't interfere with the rest of my sites.
Is there anyway that a lack of spam and virus filtering could effect me. As in, if a hacker sends a PHP file to username#myawesomedomain.com, is there any way that my server could be affected.
Whatever else you feel is needed.
I've heard of Postfix but I don't know much about mail servers...
Sorry for the long(?) question and thank you in advance.
edit
Should I put this on ServerFault instead?
The "creating an email alias from php"-part is not a problem. If you're running postfix as a mail server it's as simple as inserting a row into a mysql table.
INSERT INTO myaliastable (pattern, alias) VALUES ("john#myawesomedomain.com","john#example.net")
see:
http://www.postfix.org/MYSQL_README.html
http://www.postfix.org/postconf.5.html#virtual_alias_maps
BUT:
creating a forwarder service like this comes with a lot of problems you should be aware of:
you MUST verify the target email adress before you enable that forwarder(send message, have the recipient click on a link) or spammers will signup accounts and use your system as open relay
you MUST run a very good spamfilter... forwarding spam is no different from sending spam and will get your server blacklisted
if a target server starts rejecting your forwarder for any reason you will be sending backscatter which again can get your server blacklisted
if the sender domain uses SPF records and the target of the forwarder checks SPF, forwarded mail will be rejected. you could add SRS rewrites, which unfortunately is not that simple in postfix
since you state you don't know much about mailservers I would strongly advise to read up on them first, check out best practices on spam prevention and then tackle this project again.

PHP mails going into spam from Amazon Ec2

I have an application hosted on amazon EC2. Now a user can send out invitations to join but on most email clients its showing up in the spam folder. Is there anyway to find out on what criteria it is actually being filtered.
First of all, please check to see if your domain/IP has landed on any blacklists:
https://www.mxtoolbox.com/blacklists.aspx
Second of all, have you set an SPF record? Explanation below:
http://www.openspf.org/Introduction
https://mxtoolbox.com/spf.aspx
This is a way to qualify a particular server/IP as being a valid for relaying/sending mail on behalf of a particular domain. Sendmail - or whatever PHP is configured to use to send mail - can actually send mail for any user on any domain (i.e. "spoofing"). However the server receiving the mail (e.g. a recipients POP3 server where received mail is stored and filtered) is probably going to check whether or not that server is supposed to be sending mail for that domain based on what's in the domain's DNS entries. In particular, it will probably check the SPF record, so you will need to set this. You should consult whichever service manages your DNS (i.e. your nameservers) for how to do this. You can look up where your nameservers are using the whois, dig or nslookup commands (or just use a web based whois service) - look for the "nameserver" entries, often denoted by "ns".
This is one of a number of factors that may be affecting whether or not your mail goes to spam. This subject is something of a "can of worms" and goes way beyond setting up your PHP mail function correctly. Rather than trying to reiterate all of these issues here, I'll direct you to this post on serverfault:
https://serverfault.com/questions/106598/all-my-emails-to-yahoo-hotmail-and-aol-are-going-to-spam-though-ive-implemen
Do you use 5th parameter in mail function?
mail('reciever#address.com', 'the subject', 'the message', null,
'-fyour#address.com');
It helps sometime.
Also maybe your IP was blocked before you start to use it.

Create a random disposable mail receiver

I need to create random e-mail addresses that possess the role of receivers. Though these addresses should not be in any case real e-mails. I know that this kind of problem could easily be solved by creating something like Random_root#dummy_host.com . But the real deal is that there's a case my CMS will notify via e-mail these accounts, and so in this case the server will have a re-bounce mail traffic or even worse the host could be black-listed as spam.
I am thinking a mail server that dispose any kind of non existed mail address at its host but I can't find any applicable.
Thanks in advance!
Though not a PHP solution there is a web based service that runs off an API you can use, take a look at http://mailgun.net/
Again not a direct PHP solution but http://cloudmailin.com will allow you to send to any email address at your domain, you can then use a 403 status in your app to reject email to anything you're not expecting and the mail server will actually refuse the message.

PHP sending emails through random email accounts

I'm working on a website that allows you to send emails without registering, and without specifying a sender. You enter the recipient's address, subject, body and send. My problem is sending the message. What I'm trying to achieve:
User clicked send -> Subject,recipient,body sent to PHP -> Server validates the information -> Server creates a random email account -> Server sends the email through the random account created -> Server deletes the account
I'm stuck at the random email account creation step. How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
I googl'd the hell out of this issue and I can't find an answer.
Thanks!
BTW
I'm using Apache to "host" on my own Ubuntu
How do I achieve this with PHP without having to pay for my own SMTP server and without having to use my own gmail/hotmail account.
The way to create E-Mail accounts varies wildly from server software to server software, and is usually not possible from within PHP.
Depending on your server's configuration, though, that might not be necessary: If you set up a catch all address for a domain, many server configurations will allow you to send out mails from any E-Mail on that domain (e.g. 123456789#example.com). Any responses will then go to that catch-all mailbox, the contents of which you will probably want to discard.
You have to realize, though, that this is exactly how spam providers operate. Extreme caution is advised if you don't want to end up on all sorts of spam blacklists.
I don't believe you can create accounts or email accounts on a server, using PHP, as this supersedes PHP's permission level. Sending emails this way is a good way to get your server banned, FYI. Also, if you insist on sending emails like this, why not just specify a dummy From: email address? It would essentially be the same thing as creating a dummy account anyhow.
You may also want to use the -f switch, for PHP's mail(). See php.net/manual/en/function.mail.php

Categories