Topic: eform SMTP  (Read 1214 times)

Pages: [1]   Go Down

#1: 2-Dec-2008, 11:25 PM

marcello
Posts: 5

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

#2: 3-Dec-2008, 08:35 AM

Moderator

TobyL
Posts: 1,024

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?

#3: 3-Dec-2008, 09:16 AM

marcello
Posts: 5

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

thx

#4: 3-Dec-2008, 09:28 AM


shamblett
Posts: 657

WWW
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.
Use MODx, or the cat gets it!

#5: 3-Dec-2008, 01:19 PM

marcello
Posts: 5

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)

#6: 3-Dec-2008, 02:26 PM


shamblett
Posts: 657

WWW
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.
Use MODx, or the cat gets it!

#7: 3-Dec-2008, 04:09 PM

marcello
Posts: 5

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,

#8: 3-Dec-2008, 04:44 PM

Testers

dev_cw
Posts: 4,179

WWW
Try changing &to=`[(email_sender)]` to &to=`youremail@address.com`
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]

#9: 3-Dec-2008, 05:33 PM

Coding Team

BobRay
Posts: 5,300

WWW
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.

MODx info for newbies: http://bobsguides.com/MODx.html

#10: 3-Dec-2008, 09:57 PM

marcello
Posts: 5

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

#11: 3-Dec-2008, 11:07 PM

Coding Team

BobRay
Posts: 5,300

WWW
Good solution. Glad you got it sorted.  Smiley
MODx info for newbies: http://bobsguides.com/MODx.html
Pages: [1]   Go Up
0 Members and 1 Guest are viewing this topic.