By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,956 Members | 1,683 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,956 IT Pros & Developers. It's quick & easy.

Accessing SMTP direct instead of using mail()

P: n/a
My shared web host has made some sort of upgrade to .. something .. the
support tech can't tell me what. It's a cPanel system, with all the
regular stuff. The site is a club site.

For years, I have been using the regular old mail(...) function for
things like sending broadcast messages to members. Yesterday, that
failed. The host now tells me I need to access the SMTP server directly,
using a valid email account and password. "It's a new security measure
to prevent spamming. Go find a script," was the tech's reply.

I found one, at:
http://us3.php.net/manual/en/ref.mail.php
2/3rds down, search the page for:
josephcmiller2 at gmail dot com

Port 25 doesn't work; the tech finally told me to try port 587. That
helps. No authentication is required, he said. However, the script fails
at:

// Say hello...
fputs($cp, "HELO ".$GLOBAL["SMTP_SERVER"]."\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "Failed to Introduce";

...and I don't know what to do after that. $GLOBAL["SMTP_SERVER"]
contains the name of the server, ("mail.example.com") which works for
the fsockopen() code preceding the HELO lines. Any ideas, folks?

--
-bts
-Friends don't let friends drive Windows
Jun 27 '08 #1
Share this Question
Share on Google+
13 Replies


P: n/a
Beauregard T. Shagnasty wrote:
My shared web host has made some sort of upgrade to .. something .. the
support tech can't tell me what. It's a cPanel system, with all the
regular stuff. The site is a club site.

For years, I have been using the regular old mail(...) function for
things like sending broadcast messages to members. Yesterday, that
failed. The host now tells me I need to access the SMTP server directly,
using a valid email account and password. "It's a new security measure
to prevent spamming. Go find a script," was the tech's reply.

I found one, at:
http://us3.php.net/manual/en/ref.mail.php
2/3rds down, search the page for:
josephcmiller2 at gmail dot com

Port 25 doesn't work; the tech finally told me to try port 587. That
helps. No authentication is required, he said. However, the script fails
at:

// Say hello...
fputs($cp, "HELO ".$GLOBAL["SMTP_SERVER"]."\r\n");
$res=fgets($cp,256);
if(substr($res,0,3) != "250") return "Failed to Introduce";

..and I don't know what to do after that. $GLOBAL["SMTP_SERVER"]
contains the name of the server, ("mail.example.com") which works for
the fsockopen() code preceding the HELO lines. Any ideas, folks?
Get phpmailer. It handles all of that.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #2

P: n/a
Jerry Stuckle wrote:
Beauregard T. Shagnasty wrote:
>My shared web host has made some sort of upgrade to ..

Get phpmailer. It handles all of that.
I looked at that during my search. It appears to me it needs to be
installed on the *shared* web host, and I don't see how I can do that.

(The search also turned up some results that said
http://www.swiftmailer.org/
is even better, but the same restrictions apply.)

I can't do this on my home PC as there is an online associated members'
database maintained by the membership chairman of the year, who also
needs to use some of the mailing functions. Club officers also have some
access to certain functions.

--
-bts
-Friends don't let friends drive Windows
Jun 27 '08 #3

P: n/a
..oO(Beauregard T. Shagnasty)
>Jerry Stuckle wrote:
>Beauregard T. Shagnasty wrote:
>>My shared web host has made some sort of upgrade to ..

Get phpmailer. It handles all of that.

I looked at that during my search. It appears to me it needs to be
installed on the *shared* web host, and I don't see how I can do that.
Just upload it to some directory on your host and include the two
classes in your script, that's all. No further installation necessary.
The configuration can be set at runtime.

Micha
Jun 27 '08 #4

P: n/a
Beauregard T. Shagnasty wrote:
Jerry Stuckle wrote:
>Beauregard T. Shagnasty wrote:
>>My shared web host has made some sort of upgrade to ..
Get phpmailer. It handles all of that.

I looked at that during my search. It appears to me it needs to be
installed on the *shared* web host, and I don't see how I can do that.

(The search also turned up some results that said
http://www.swiftmailer.org/
is even better, but the same restrictions apply.)

I can't do this on my home PC as there is an online associated members'
database maintained by the membership chairman of the year, who also
needs to use some of the mailing functions. Club officers also have some
access to certain functions.
Nope, you can put it on your website then include the classes. It works
fine with shared hosts. If you have access to the directory below your
webroot, I recommend placing it there (where I place all include files).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #5

P: n/a
the problem with normal classes is, that they all cant handle the TLS
encoding google wants you to use. Because of this google rejects the
connection. I dont know whether phpmailer can handle this but normal
scripts, you find will only work with other smtp servers
Jun 27 '08 #6

P: n/a
Martin wrote:
the problem with normal classes is, that they all cant handle the TLS
encoding google wants you to use. Because of this google rejects the
connection. I dont know whether phpmailer can handle this but normal
scripts, you find will only work with other smtp servers
He's not using gmail, so the point is moot. But phpmailer does handle
TLS security quite well.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #7

P: n/a
On Tue, 3 Jun 2008 11:08:33 -0700 (PDT), Martin wrote:
the problem with normal classes is, that they all cant handle the TLS
encoding google wants you to use. Because of this google rejects the
connection. I dont know whether phpmailer can handle this but normal
scripts, you find will only work with other smtp servers
http://www.xpertmailer.com/ as referenced at
http://us2.php.net/manual/en/ref.mail.php#82433

Is there anything else you need on this silver platter?

--
88. If a group of henchmen fail miserably at a task, I will not berate them
for incompetence then send the same group out to try the task again.
--Peter Anspach's list of things to do as an Evil Overlord
Jun 27 '08 #8

P: n/a
Peter H. Coffin wrote:
On Tue, 3 Jun 2008 11:08:33 -0700 (PDT), Martin wrote:
>the problem with normal classes is, that they all cant handle the TLS
encoding google wants you to use. Because of this google rejects the
connection. I dont know whether phpmailer can handle this but normal
scripts, you find will only work with other smtp servers

http://www.xpertmailer.com/ as referenced at
http://us2.php.net/manual/en/ref.mail.php#82433

Is there anything else you need on this silver platter?
Hey,
I've written a tutorial on doing this with pear mail, with uthentication
and tls, and without.

http://phpmaniac.net/wiki/index.php/...ing_using_SMTP

leigh
Jun 27 '08 #9

P: n/a
Michael Fesser wrote:
.oO(Beauregard T. Shagnasty)
>>Jerry Stuckle wrote:
>>Beauregard T. Shagnasty wrote:
My shared web host has made some sort of upgrade to ..

Get phpmailer. It handles all of that.

I looked at that during my search. It appears to me it needs to be
installed on the *shared* web host, and I don't see how I can do
that.

Just upload it to some directory on your host and include the two
classes in your script, that's all. No further installation
necessary. The configuration can be set at runtime.
I've been playing with phpmailer. After some modification - and
rewriting some of the mailing scripts/pages - it works after a fashion.
Heh, 90-something KB to replace one mail() line.

Oh, and this. I just got a 'followup' from the tech guy, who says, "Your
normal php mail() function should now be working."

Duh... Last night I wasn't allowed to use it.

--
-bts
-Friends don't let friends drive Windows
Jun 27 '08 #10

P: n/a
..oO(Beauregard T. Shagnasty)
>I've been playing with phpmailer. After some modification - and
rewriting some of the mailing scripts/pages - it works after a fashion.
Heh, 90-something KB to replace one mail() line.
You'll soon learn that PHPMailer is much more powerful and far more
convenient than the simple mail() function, where you would have to do a
lot of things by hand, especially if you want to send multi-part mails.

The only things that I don't like about PHPMailer are some of the method
names, which are misleading. For example isHtml() shouldn't set the used
mode, but just return a TRUE or FALSE. Anyway, such things are easy to
fix with a wrapper class if necessary, the rest is just working fine.

Micha
Jun 27 '08 #11

P: n/a
Beauregard T. Shagnasty wrote:
Michael Fesser wrote:
>.oO(Beauregard T. Shagnasty)
>>Jerry Stuckle wrote:
Beauregard T. Shagnasty wrote:
My shared web host has made some sort of upgrade to ..
Get phpmailer. It handles all of that.
I looked at that during my search. It appears to me it needs to be
installed on the *shared* web host, and I don't see how I can do
that.
Just upload it to some directory on your host and include the two
classes in your script, that's all. No further installation
necessary. The configuration can be set at runtime.

I've been playing with phpmailer. After some modification - and
rewriting some of the mailing scripts/pages - it works after a fashion.
Heh, 90-something KB to replace one mail() line.

Oh, and this. I just got a 'followup' from the tech guy, who says, "Your
normal php mail() function should now be working."

Duh... Last night I wasn't allowed to use it.
Hmmm, not sure why you had to rewrite some of the scripts. The couple
of times I've used it it's worked fine. But you must have some really
off-the-wall requirements from your host.

Interesting that now mail() works. They must have had a bunch of
complaints from their users.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jun 27 '08 #12

P: n/a
Michael Fesser wrote:
.oO(Beauregard T. Shagnasty)
>I've been playing with phpmailer. After some modification - and
rewriting some of the mailing scripts/pages - it works after a
fashion. Heh, 90-something KB to replace one mail() line.

You'll soon learn that PHPMailer is much more powerful and far more
convenient than the simple mail() function, where you would have to
do a lot of things by hand, especially if you want to send multi-part
mails.
I'll agree it's powerful. However, it far exceeds my needs, which
consist only of sending short text messages^1 to broadcast events to our
members, to confirm registrations (about 150 ten-line messages per
summer), a little members-only "forum", and the contact page. There are
never attachments nor embedded graphics, for example.

But I'll still do some more experimenting with it.

1. HTML is for web pages <g>

--
-bts
-Friends don't let friends drive Windows
Jun 27 '08 #13

P: n/a
Jerry Stuckle wrote:
Interesting that now mail() works. They must have had a bunch of
complaints from their users.
It worked for one run of a half-dozen individual messages to rally
registrants.

Then it failed on a broadcast of coming events to the club members. Club
email address in TO: and a hundred members in BCC:. That script is
unmodified for years.

I reopened the trouble ticket. :-(

--
-bts
-Friends don't let friends drive Windows
Jun 27 '08 #14

This discussion thread is closed

Replies have been disabled for this discussion.