Jul 05, 2009, 09:10 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Read what MODx Developers say: MODx Dev. Blogs
Pages: [1]   Go Down
  Print  
Author Topic: eform SMTP  (Read 842 times)
0 Members and 1 Guest are viewing this topic.
marcello
Jr. Member
*
Posts: 5


« on: Dec 02, 2008, 11:25 PM »

Hi,

I am having trouble to make eform to work with my host provider (DreamHost). I am required to use SMTP, with no authentication.

I have made the following changes to eform.inc.php to add SMTP method. The change was done to all sections that have the class PHPMailer in the eform.inc.php
...
$mail = new PHPMailer();
#$mail->IsMail();
$mail->IsSMTP();
$mail->Host = "localhost";
$mail->SMTPAuth = false;
$mail->Mailer = "smtp";

...

I am testing it with the default "contact us" page. hit on submit and receive the successful notification, but no email...  Sad

So I tested a similar approach  (below) outside modx and phpmailer is able to send out emails. Any ideas?  Any property or parameter  I might be missing from the code above?

<?php
require("./manager/includes/controls/class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(true);        // set mailer to use SMTP
$mail->Host = "localhost";  // specify main and backup server
$mail->SMTPAuth = false;    // turn off SMTP authentication
$mail->From = "test@domain";
$mail->FromName = "anyname";
$mail->AddAddress("xyz@yahoo.com", "Name1");
$mail->IsHTML(true);       // set email format to HTM
$mail->Subject = "PHPmailer example";
$mail->Body    = "This is a test of email 2";
if(!$mail->Send()){
        echo "Message could not be sent. <p>";
        echo "Mailer Error: " . $mail->ErrorInfo;
        exit;
        }
?>


Thanks,
marcello

Logged
TobyL
Moderator
*
Posts: 1,006



« Reply #1 on: Dec 03, 2008, 08:35 AM »

In your test outside eForm you have
Code:
$mail->IsSMTP(true);        // set mailer to use SMTP
and in the eForm code you have
Code:
$mail->IsSMTP();

Could that have something to do with it?
Logged

marcello
Jr. Member
*
Posts: 5


« Reply #2 on: Dec 03, 2008, 09:16 AM »

The "true" is not a required parameter. But I added it to the eform.inc.php and got same results.  Sad

thx
Logged
shamblett
Sr. Member
****
Posts: 499



WWW
« Reply #3 on: Dec 03, 2008, 09:28 AM »

Check your localhost mail logs when you hit submit,  this should tell you how far the mail request is getting and what's happening to it.
Logged

Use MODx, or the cat gets it!
marcello
Jr. Member
*
Posts: 5


« Reply #4 on: Dec 03, 2008, 01:19 PM »

I confirmed with my host provider, and messages are not reaching the mailserver.  The only messages found on the mailserver log are the ones I sent out using the test script outside Modx. So Modx is not reaching the mailserver... Any ideas on where else should I look? And I see no error message when submitting the form...

Code:
/var/log/mail.log.1.gz:Dec  2 20:13:29 pants postfix/smtp[18692]:
43BEB14C009: to=<xyx@yahoo.com>,
relay=e.mx.mail.yahoo.com[216.39.53.1], delay=1, status=sent (250 ok
dirdel)
/var/log/mail.log.1.gz:Dec  2 20:15:27 pants postfix/smtp[18693]:
ABC4414C008: to=<xyx@yahoo.com>,
relay=g.mx.mail.yahoo.com[206.190.53.191], delay=3, status=sent (250 ok
dirdel)
/var/log/mail.log.1.gz:Dec  2 20:17:02 pants postfix/smtp[18635]:
7335214C004: to=<xyx@yahoo.com>,
relay=c.mx.mail.yahoo.com[216.39.53.2], delay=300, status=sent (250 ok
dirdel)
/var/log/mail.log.1.gz:Dec  2 20:35:44 pants postfix/smtp[19535]:
1BF1214C00A: to=<xyx@yahoo.com>,
relay=d.mx.mail.yahoo.com[66.196.82.7], delay=1, status=sent (250 ok
dirdel)
Logged
shamblett
Sr. Member
****
Posts: 499



WWW
« Reply #5 on: Dec 03, 2008, 02:26 PM »

Ok, on the one that fails i.e in the internal MODx code you do this :-
Quote
$mail->Mailer = "smtp";
You don't do this on the example that works. I believe this sets what the smtp mail daemon is which may be wrong for your platform, delete ths line and try your e-form again, watching the logs of course.
Logged

Use MODx, or the cat gets it!
marcello
Jr. Member
*
Posts: 5


« Reply #6 on: Dec 03, 2008, 04:09 PM »

All the PHPMailer code look like this now. I have also updated to version 1.4.4.5

Code:
$mail = new PHPMailer();
#$mail->IsMail();
$mail->IsSMTP();
$mail->Host = "localhost";
$mail->SMTPAuth = false;
#$mail->Mailer = "smtp";
$mail->IsHTML($isHtml);

Same results. Nothing reaches the mailserver.

Just in case.. here is the contents of my form page.

Code:
[!eForm? &formid=`ContactForm` &subject=`[+subject+]` &to=`[(email_sender)]` &ccsender=`1` &tpl=`ContactForm` &report=`ContactFormReport` &invalidClass=`invalidValue` &requiredClass=`requiredValue` &cssStyle=`ContactStyles` &gotoid=`46`  !]

Thanks,
Logged
dev_cw
Testers
*
Posts: 4,025



WWW
« Reply #7 on: Dec 03, 2008, 04:44 PM »

Try changing &to=`[(email_sender)]` to &to=`youremail@address.com`
Logged

Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

Something is happening here, but you don't know what it is.
Do you, Mr. Jones?  -  [bob dylan]
BobRay
Coding Team
*
Posts: 3,177



WWW
« Reply #8 on: Dec 03, 2008, 05:33 PM »

This is line 199 or the class.phpmailer.php file:

Code:
var $SMTPDebug    = false;

I'm not sure if it will accept that as an argument, you may have to edit the line. It might give you a clue.

Logged

MODx info for newbies: http://bobsguides.com/MODx.html
marcello
Jr. Member
*
Posts: 5


« Reply #9 on: Dec 03, 2008, 09:57 PM »

Thanks guys...

Changing  &to=`[(email_sender)]` to &to=`youremail@address.com`  worked fine. The email_sender was already defined in the configuration, and I could not understand why it was not being parsed.  Huh

So I checked the eform.inc.php once again and changed the following:

Code:
Version 1.4.4.5

Commented Line 458 -> #AddAddressToMailer($mail,"to",$to);
Added Line 459 ->  AddAddressToMailer($mail,"to",$modx->config['emailsender']);


This way  I do not have to hard code the email address on the contact form and eform will use the "to" from the email address (emailsender) defined under manager->tools->configuration->user->email address

Thank you very much.
Marcello
Logged
BobRay
Coding Team
*
Posts: 3,177



WWW
« Reply #10 on: Dec 03, 2008, 11:07 PM »

Good solution. Glad you got it sorted.  Smiley
Logged

MODx info for newbies: http://bobsguides.com/MODx.html
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF | SMF © 2006-2008, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!