We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 18231
    • 5 Posts
    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("[email protected]", "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

      • 30223
      • 1,010 Posts
      In your test outside eForm you have
      $mail->IsSMTP(true);        // set mailer to use SMTP

      and in the eForm code you have
      $mail->IsSMTP();


      Could that have something to do with it?
        • 18231
        • 5 Posts
        The "true" is not a required parameter. But I added it to the eform.inc.php and got same results. sad

        thx
          • 26903
          • 1,336 Posts
          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!
            • 18231
            • 5 Posts
            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...

            /var/log/mail.log.1.gz:Dec  2 20:13:29 pants postfix/smtp[18692]:
            43BEB14C009: to=<[email protected]>,
            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=<[email protected]>,
            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=<[email protected]>,
            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=<[email protected]>,
            relay=d.mx.mail.yahoo.com[66.196.82.7], delay=1, status=sent (250 ok
            dirdel)
              • 26903
              • 1,336 Posts
              Ok, on the one that fails i.e in the internal MODx code you do this :-
              $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!
                • 18231
                • 5 Posts
                All the PHPMailer code look like this now. I have also updated to version 1.4.4.5

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

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


                Thanks,
                  • 7231
                  • 4,205 Posts
                  Try changing &to=`[(email_sender)]` to &to=`[email protected]`
                    [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                    Something is happening here, but you don&#39;t know what it is.
                    Do you, Mr. Jones? - [bob dylan]
                    • 3749
                    • 24,544 Posts
                    This is line 199 or the class.phpmailer.php file:

                    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.

                      Did I help you? Buy me a beer
                      Get my Book: MODX:The Official Guide
                      MODX info for everyone: http://bobsguides.com/modx.html
                      My MODX Extras
                      Bob's Guides is now hosted at A2 MODX Hosting
                      • 18231
                      • 5 Posts
                      Thanks guys...

                      Changing &to=`[(email_sender)]` to &to=`[email protected]` 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:

                      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