Jump to content

Recommended Posts

Posted

Hello Clever People,



I got to say that I am pleasantly surprised with Heliohost... I almost have my test site working, just a few little things left to fix.

When a person registers on my site, the site sends a little No Reply confirmation message to the new user. Typical web site stuff.
I'm using a Yahoo mail to send the message, not the same as my CPanel log in email address.

The SMTP connection on the server is being refused.

I see in CPanel a ton of options, but I think that is for people that want to use your server as a email host.
Perhaps is better to let Yahoo take the traffic...

So how do I do this, do I need to create an email account and use that, or can I just enable the existing email address. That's all this email address does, send confirmations... low traffic.

Not sure how you would like me to do it?

The email address is
diybookie(AT Sign)yahoo.com
if you need it.

 



Thanks Bob

Posted

You can make a domain receive mail using an external mail server by changing the MX records, but I don't think we can automatically use an external SMTP server for sending everything on an account. No idea why the server would refuse connection though unless Yahoo blocked us or our firewall is in the way (shouldn't be, assuming Yahoo uses standard mail ports).

 

Krydos will probably have more of an idea as to why this might be failing. Escalating.

Posted

OK, don't worry I'm using your email accounts... but perhaps you might want to talk about 3rd party emails, if possible.
Thanks Bob



Ah thanks... yes perhaps later when we get a proper domain name.

I know when I tried to setup Debian to send to outside email providers, that its complicated because they have all become paranoid and don't like the idea because of spammers and hackers.

So I used yours... it works thanks...

Posted

I would use Pear mail to send emails with smtp through yahoo's servers. The default php mail() command is pretty basic and fine for sending email from our servers, but to connect to an external smtp server with ssl you're going to need more.

 

Go to https://tommy.heliohost.org:2083/frontend/paper_lantern/module_installers/search.html?searchterm=mail&lang=php-pear&searchtype=1 and install pear mail.

 

Then use the line

require_once("/home/bobspar1/php/Mail.php");
to load the pear mail into your script. Then you can use something like this to connect to yahoo

<?php
require_once("/home/bobspar1/php/Mail.php");
 
$from = "Bob Spar <diybookie@yahoo.com>";
$to = "Some User <whatever@example.com>";
$subject = "Hi!";
$body = "Hi,\n\nHow are you?";
 
$host = "ssl://smtp.mail.yahoo.com";
$port = "465";
$username = "diybookie@yahoo.com";
$password = "smtp_password";
 
$headers = array ('From'    => $from,
                  'To'      => $to,
                  'Subject' => $subject);
$smtp = Mail::factory('smtp',
  array ('host'     => $host,
         'port'     => $port,
         'auth'     => true,
         'username' => $username,
         'password' => $password));
 
$mail = $smtp->send($to, $headers, $body);
 
if (PEAR::isError($mail)) {
  echo("<p>" . $mail->getMessage() . "</p>");
} else {
  echo("<p>Message successfully sent!</p>");
}
I haven't tested the code above, but it should be close to what you could use.

 

I tested the connection to smtp.mail.yahoo.com and it's not blocked.

Posted (edited)

Hello Clever People...

 

I have a Helio Email account which works perfectly as a normal email account.

 

I have a PHP client that send registration confirmation in the site.

It seems to work... but nothing comes out the other side...

I list the test output for you below of SMTP conversation between client and server...

There seems to be no problem.. other than possibly this client is PHPMailer 5.2.8 and the mail server doesn't like it perhaps... it doesn't complain... but it also never sends the message...

 

I don't think its specific to the SMTP on the server, because even if I do it from my server... goes OK, but also never comes... so I suspect its a spam filter active of some kind... or I just cant use CPanel properly yet and I have to set something. This is strictly for confirming registrations, will never be used for anything else.

 

Thanks Bob[/size][/size]

 

 

-------------[/size]

 

CLIENT -> SERVER: EHLO diybookmaker.heliohost.org

SERVER -> CLIENT: 250-johnny.heliohost.org Hello johnny.heliohost.org [64.62.211.131]250-SIZE 52428800250-8BITMIME250-PIPELINING250-AUTH PLAIN LOGIN250 HELP

CLIENT -> SERVER: AUTH LOGIN

SERVER -> CLIENT: 334 VXNlcm5hbWU6

CLIENT -> SERVER: aW5mb0BkaXlib29rbWFrZXIuaGVsaW9ob3N0Lm9yZw==

SERVER -> CLIENT: 334 UGFzc3dvcmQ6

CLIENT -> SERVER: ZGFwYXNzNE1Fbm90VQ==

SERVER -> CLIENT: 235 Authentication succeeded

CLIENT -> SERVER: MAIL FROM:<info@diybookmaker.heliohost.org>

SERVER -> CLIENT: 250 OK

CLIENT -> SERVER: RCPT TO:<diybookie@yahoo.com>

SERVER -> CLIENT: 250 Accepted

CLIENT -> SERVER: DATA

SERVER -> CLIENT: 354 Enter message, ending with "." on a line by itself

CLIENT -> SERVER: Date: Sat, 8 Jul 2017 17:23:11 +0000

CLIENT -> SERVER: To: Mr Test <diybookie@yahoo.com>

CLIENT -> SERVER: From: Do Not Reply <info@diybookmaker.heliohost.org>

CLIENT -> SERVER: Reply-To: Do Not Reply <info@diybookmaker.heliohost.org>

CLIENT -> SERVER: Subject: Mail Test

CLIENT -> SERVER: Message-ID: <a960fb135cf51709541bc2cc3a158e95@diybookmaker.heliohost.org>

CLIENT -> SERVER: X-Priority: 3

CLIENT -> SERVER: X-Mailer: PHPMailer 5.2.8 (https://github.com/PHPMailer/PHPMailer/)

CLIENT -> SERVER: MIME-Version: 1.0

CLIENT -> SERVER: Content-Type: multipart/alternative;

CLIENT -> SERVER: boundary="b1_a960fb135cf51709541bc2cc3a158e95"

CLIENT -> SERVER: Content-Transfer-Encoding: 8bit

CLIENT -> SERVER:

CLIENT -> SERVER: --b1_a960fb135cf51709541bc2cc3a158e95

CLIENT -> SERVER: Content-Type: text/plain; charset=us-ascii

CLIENT -> SERVER:

CLIENT -> SERVER: Some Info

CLIENT -> SERVER:

CLIENT -> SERVER:

CLIENT -> SERVER: --b1_a960fb135cf51709541bc2cc3a158e95

CLIENT -> SERVER: Content-Type: text/html; charset=us-ascii

CLIENT -> SERVER:

CLIENT -> SERVER: Some Html Info

CLIENT -> SERVER:

CLIENT -> SERVER:

CLIENT -> SERVER:

CLIENT -> SERVER: --b1_a960fb135cf51709541bc2cc3a158e95--

CLIENT -> SERVER:

CLIENT -> SERVER: .

SERVER -> CLIENT: 250 OK id=1dTtRo-0007kc-6D

CLIENT -> SERVER: QUIT

SERVER -> CLIENT: 221 johnny.heliohost.org closing connection[/size]

 

 

 

 

 

Ah... I see it now... its now putting this at the top...

 

/home/bobspar1/public_html/go/php/libsSERVER -> CLIENT: 220-johnny.heliohost.org ESMTP Exim 4.88 #1 Sat, 08 Jul 2017 10:47:27 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

 

Question them becomes... how does one do Email confirmations of registration... I can use an external mail server, but then SMTP will reject me... please advise, thanks.

 

 

Ah... I see it now... its now putting this at the top...

 

/home/bobspar1/public_html/go/php/libsSERVER -> CLIENT: 220-johnny.heliohost.org ESMTP Exim 4.88 #1 Sat, 08 Jul 2017 10:47:27 -0700 220-We do not authorize the use of this system to transport unsolicited, 220 and/or bulk e-mail.

 

Question them becomes... how does one do Email confirmations of registration... I can use an external mail server, but then SMTP will reject me... please advise, thanks.

Edited by Krydos
reduced font size
Posted

Merging threads.

 

Have you tried my code? I can't tell from your log file if you're using port 25 or port 465 with ssl?

Posted (edited)

Thanks... it seems to be working now... this PHPMailer 5.2.8 lib is not bad... Yeah, the standard PHP mail engine sucks for want of a better word... thus I'm using the PHPMailer third party lib... seems to work OK.

 

But yes, this exercise has got me thinking... I think my next move will be to tie into the Google or Yahoo clouds and just send HTTP requests to the those huge engines... I think the email will be instantaneous... probably not free, don't know yet.

 

But yes... PHP is a damn good scripting language but its weak in Email and in background tasks... agreed, anything else is better in that area :)

 

So far I have been able to make the site without tying into PHP addons... trying to stay there if I can.

 

You guys have an amazing array of tools, I doubt whether other hosting services come close to your software stack.

In the main... I just like KISS...

 

Well, I think I almost have this test site up on Heliohost... good on you guys :) Thanks[/size]

Edited by Krydos
large fonts hurt my eyes
Posted

Hi Krydos,

 

I have been out of software development for about 7 years... I thought, well I'll just go to the Google API engine and make a mail web service, man! the internet has changed, no longer do they say "hey developers, come make a web service", now its one gigantic "click and pay" shopping center. Cant say I like this new internet much. Developers seem to have been forgotten now that these large organizations own the world. Consolidation I think they call it in business, no fun for developers is what it feels like.

I think you right, the easiest way to get this test system up is going to be your PEAR idea... just have a few questions.

1) I'm testing on Johnny and I don't see the PEAR module?

2) Why will Pear be able to SMTP emails, but a PHP library cant, is that just policy, or some technical limitation, just curious.
3) Does PEAR do the email as a background task, or does the browser "freeze" while the email goes?

4) Finally if Tomcat is able to send SMTP requests, and if you want, I could make a background mailer specifically for registration confirmation. Its just that Java has
great threading and so the PHP code, or any other code returns immediately from the simple Post.
We could put a 10 line limit on emails or something like that to make it specifically for tiny emails, no pics, no attachments... no spam, and they going through their own mail provider, so no disk space, but you would have to enable SMTP for the war app on tomcat? That code will be handy later for other projects.

 

Mailing from web apps is much more of a mission than I expected... if I get the PEAR thing going, I will probably settle for that for the test site, but if she cant send in the background, I'll have to make something better later. There is a trick in PHP to simulate background tasks using Async Sockets... but for some reason they don't seem to fire up on Johnnies PHP, probably some setting somewhere. So PHP can be made to do this stuff, but it seems security measures get in the way.
It seems that a little web service may be the way to go... on Java Tomcat.

 

  • Anyway, if you can just show me how to get Pear installed on Johnny, I'll give it a go...
  • If SMTP will work on Tomcat... I can go that route as well... and that is something everyone on the site can use... POST, done...

 

Thanks for your help...
Bob

Posted

OK... don't worry for now, I managed to find a kludge... I put a primitive PHP web service on another server, and I call it with a POST from this server... it works but its not a great solution. But enough for the boss man to now play with the thing :)

At some stage I'll find a better solution... Java Servlets are damn good at doing this... web pages return immediately... maybe later.

Now I just hope the boss man likes it... then there will be some work for all of us, hopefully... it will have to be moved to a production server, security and all that good stuff, and I now know you guys will be good at that. I'll chat more when the time comes.

Thanks... if you ever want the code for that Emailing Java Servlet... I can dig it out of the archives... just a web service.. Receives a post, starts a background thread, return to caller and then tries to send the email up to 3 times... simple thing, but it makes the user experience nice.
The PHP trick would require turning on a few things... but its not using threads, its actually launching a new process, not the best way.

Later... thanks again... Bob



Actually just to make this thread a little more useful to PHP guys, here is what the code looks like that calls my little web service... no email stuff in your program... but of course the web service must be there... just so you can see what I been waffling on about... its a POST from the code.

 

 


function do_post_request($url, $data, $optional_headers = null)
{
$params = array('http' => array(
'method' => 'POST',
'content' => $data
));
if ($optional_headers!== null) {
$params['http']['header'] = $optional_headers;
}
$ctx = stream_context_create($params);
$fp = @fopen($url, 'rb', false, $ctx);
if (!$fp) {
throw new Exception("Problem with $url, $php_errormsg");
}
$response = @stream_get_contents($fp);
if ($response === false) {
throw new Exception("Problem reading data from $url, $php_errormsg");
}
return $response;
};
//Using this as a kludge because mailing does not work...
//I use a remote PHP mail server... its a kludge


function sendMailRemote($tomailIN, $nameIN, $subjectIN,$htmlinfoIN,$textinfoIN)
{

$url = "http://TheMailWeService";

$tomail = urlencode($tomailIN);
$name = urlencode($nameIN);
$subject = urlencode($subjectIN);
$htmlinfo = urlencode($htmlinfoIN);
$textinfo = urlencode($textinfoIN);

//$tomail = urlencode("Dude@gmail.com");
//$name = urlencode("Your Remote Ness");
//$subject = urlencode("Test Post Mail");
//$htmlinfo = urlencode("Some HTML");
//$textinfo = urlencode("Some Text");

$data = "tomail=".$tomail."&name=".$name."&subject=".$subject."&htmlinfo=".$htmlinfo."&textinfo=".$textinfo;


if(do_post_request($url, $data)){
return true;
}else{
return false;
}

};

Posted

1) I'm testing on Johnny and I don't see the PEAR module?

Oh, you're right. It's supposed to be there on Johnny, but it isn't. I have it enabled in WHM. Anyways, there's nothing special about pear module installer. Just download it manually from https://pear.php.net/package/Mail and include it in your script.

 

2) Why will Pear be able to SMTP emails, but a PHP library cant, is that just policy, or some technical limitation, just curious.

Here's some discussion http://forums.devshed.com/php-development-5/php-mail-vs-pear-mail-module-520896.html

 

3) Does PEAR do the email as a background task, or does the browser "freeze" while the email goes?

Anything can be a background task if you code it right. Check out https://stackoverflow.com/questions/5905877/how-to-run-the-php-code-asynchronous
Posted

Just out of curiosity, I had a look at that Async code... that is pretty much the async PHP kludge... but it will make Java and C++ programmers cringe...
Creating a connection and then bombing the thing closed... well who knows what will happen.

Anyway I mention it because PHP does actually have Async sockets...

$s = stream_socket_client("tcp://".$host.":".$ports[$id], $errno, $errstr, $timeout,
STREAM_CLIENT_ASYNC_CONNECT|STREAM_CLIENT_CONNECT);

 

Looks like that... and one does not have to crash the connection.

It works... its not a thread... its spawning a process... and unlike C++ languages there is no feed back as to whether it worked.
Well it depends how one looks at it... a PHP coder will say... clever stuff, I get my Async stuff working... but Java and C++ coders will think its the worst abomination they have ever seen, like smashing a screw in with a hammer :)


Its all bad coding actually... a weakness in PHP... but then that's because PHP was designed to make calls into the server completely isolated from each other.
In Java one can peek at what is happening in another call... PHP that's difficult as well, but probably good. Its strength is also its weakness.

Guest
This topic is now closed to further replies.
×
×
  • Create New...