/    Sign up×
Community /Pin to ProfileBookmark

Getting through to hotmail using mail()

I’m trying to send out a newsletter, but all my messages are being completely blocked by hotmail, the other email servies I tested worked fine.

I searched the forums and read about needing the proper content-type’s and from the examples I looked at, this should be working. I sent several emails using this code, and 2 actually did make it to my hotmail account but no others, despite using the same code.

[code=php]
$MailTitle = “”;
if(isset($_POST[“MailTitle”])){
$MailTitle = $_POST[“MailTitle”];
}
$MailMessage = “”;
if(isset($_POST[“MailMessage”])){
$MailMessage = $_POST[“MailMessage”];
}

$boundary = uniqid(‘np’);
$message = “”;

$headers = ‘From: [email protected]’ . “rn” .
‘Reply-To: [email protected]’ . “rn” .
‘X-Mailer: PHP/’ . phpversion() . “rn” .
“MIME-Version: 1.0rn” .
“Content-Type: multipart/alternative;boundary=” . $boundary . “rn”;

$message .= “rnrn–” . $boundary . “rn”;
$message .= “Content-type: text/plain;charset=utf-8rnrn”;
$message .= $MailMessage;

$message .= “rnrn–” . $boundary . “rn”;
$message .= “Content-type: text/html;charset=utf-8rnrn”;
$message .= $MailMessage;

$message .= “rnrn–” . $boundary . “–“;

mail($Email,$MailTitle,$message,$headers);

$query = “SELECT * FROM TestMailSystem”;
$result = mssql_query($query);
while($row = mssql_fetch_Array($result)){
$Email = $row[“Email”];
mail($Email,$MailTitle,$message,$headers);
}
[/code]

Does anyone see anything wrong with this code?

to post a comment
PHP

6 Comments(s)

Copy linkTweet thisAlerts:
@EbolaauthorAug 30.2006 — Also, I have about 4000 people to send this newletter to (Thanks pcthug for help on getting them in the database), and I was just wondering if the way I've set it up will be able to handle them all:

[code=php]$query = "SELECT * FROM TestMailSystem";
$result = mssql_query($query);
while($row = mssql_fetch_Array($result)){
$Email = $row["Email"];
mail($Email,$MailTitle,$message,$headers);
}[/code]


I was talking to someone about this and they said with 4000 emails it may timeout. Is there a better way to do it?
Copy linkTweet thisAlerts:
@pcthugAug 30.2006 — Many mainstream mail service providers (i.e. hotmail) are configured to automatically mark mass e-mails (Many e-mails from a single domain in a limited time frame) as spam.

[url=http://www.webdeveloper.com/forum/showthread.php?t=117758]Related Discussion[/url]
Copy linkTweet thisAlerts:
@bokehAug 30.2006 — I used to be able to send to hotmail but now I can't. It doesn't matter whether I am sending from PHP or thunderbird everything is now block (although the SMTP transfer goes fine). I have never sent spam to hotmail or anyone else for that matter. Maybe the mailserver is being block because someone else in the same "C" class has sent spam there at some time.

Anyway my method to combat this is to refused hotmail addresses from people that use any of my sites. Now I don't need to worry about hotmail and its non-standard spam methods.
Copy linkTweet thisAlerts:
@EbolaauthorAug 30.2006 — Well, the majority of those on the list don't use hotmail so I may be ok, but what about the possibility of timing out? I don't want to send out the newsletter to only half of the list :/
Copy linkTweet thisAlerts:
@netbuddyAug 30.2006 — ISP's will log how many email attempts have been made over a period of time.

My girlfriend sends emails out in batches of 35 and 40 because her ISP does not allow too many emails to be sent as they operate outbound flood control as a way of stopping the network being abused by an email spammer.

Also the HOST who is hosting your web space and giving you access to PHP may be operating flood control in the PHP settings which you wont have access to...
Copy linkTweet thisAlerts:
@sitehatcheryAug 30.2006 — Are you using MSN as your ISP? They don't have high speed Internet access that I'm aware of. I once had MSN as my ISP and I could not set outgoing emails through my local email client (Outlook), using a third party email server. I contacted MSN/Hotmail and they said that they do not allow this and there is no way to opt out of port 25 and they wouldn't tell me what other port I could use for outgoing emails. Things may have changed since then, so you might want to see if you can opt out of port 25, or use an alternative port for outgoing emails. If that doesn't work, I'd switch to another ISP that will work with you.
×

Success!

Help @Ebola spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...