CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
Pages: [1]

Author Topic: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail  (Read 5404 times)

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 08, 2009, 12:26:11 pm
Hi,

Recently installed CiviCRM.  Trying to get the SMTP outgoing mail to work.

I have done the following things:

1) Made sure PEAR Mail is installed on server (see screenshot)
2) Confirmed that my SMTP outgoing server settings actually work (by testing them in Thunderbird email client)
3) Attempted to "Save and Send Test Email" on this page /civicrm/admin/setting/smtp

Unfortunately this is what happens:
1) When I click "Save And Send Test" it just reloads the page.  I get no error nor message of success.
2) When I use CiviEvent to test sending of a confirmation email, during the confirmation screen CiviEvent says that an email cannot be sent because the SMTP settings are not configured properly.  However, see #2 above, the settings are correct.

What am I missing here?  Is there something else I must configure to get the SMTP email to work?

Thanks!

PS. I am using 2.1.6 on Drupal.
« Last Edit: March 08, 2009, 12:29:56 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 08, 2009, 01:56:29 pm

you seem to be doign the right stuff. Note that we package PEAR mail with CiviCRM. your best bet would be to:

1. add and debug the code at: CRM/Admin/Form/Setting/Smtp.php, fuction postProcess

2. packages/Mail/smtp.php, you might want to set debugging there

please let us know what the issue was so that others can benefit. Your mail log might also have some debugging clues

lobo

A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 09, 2009, 01:40:16 pm
Hi, I have attempted to debug the code in

CRM/Admin/Form/Setting/Smtp.php function postProcess and my conclusion is that this function postProcess  is not being activated at all.

this returns no status message when I click the "Save and Send Test Email" button:
Code: [Select]
    public function postProcess() {
CRM_Core_Session::setStatus( ts('Attempting to send.') );
whereas this does return a status message:
Code: [Select]
    public function buildQuickForm( ) {
CRM_Core_Session::setStatus(ts('Attempting to send.'));
so my only logical conclusion is that CiviCRM is not even getting that far to this postProcess function at all.  The behavior that the page simply reloads when I click the button with no status message lends itself to this conclusion.  Therefore I did not debug /Mail/smtp.php at all.

I lack the expertise and/or familiarity with your code to continue further without advice.  If you can please help me back up a step, what could I do to see why this form is not behaving properly?


Try CiviTeacher: the online video tutorial CiviCRM learning library.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 09, 2009, 02:19:06 pm

I would add:

CRM_Core_Error::debug( 'in postProcess' );
exit ();

and see if that works.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 09, 2009, 05:45:56 pm
Thanks.  Not being sure where to put this code, I put it in three locations and tested submitting the form each time:

Code: [Select]
#approx line 78
public function postProcess() {
CRM_Core_Error::debug( 'in postProcess' );
                exit ();

#approx line 144
CRM_Core_Error::debug( 'in postProcess' );
exit ();
        parent::postProcess();

#approx line 146
        parent::postProcess();
CRM_Core_Error::debug( 'in postProcess' );
exit ();

When I click "Save" (not save AND test) in the latter two code circumstances the script exits to a blank screen with the "in postProcess" message.

However each time I submitted the form "Save and Send Test Mail" there was no error, no debug code, and I was returned to the same page almost as if I had just refreshed the page (F5).  As I suggested earlier, I do not think that the function postProcess is malfunctioning, I think that this function is not running at all when I click "Save and Send Test Email".   

Could it be something to do with my theme?  I switched from our custom theme to the default "Garland" and get the same result.  Not the theme's problem.

My conclusion: The form is not posting properly, or more likely the post is not being interpreted properly to run the function postProcess which I click "Save and Send Test Email".  Any ideas on why?  A configuration setting?  We are running our page at www.blah.com/drupal/ is this the problem?   

Any help would be greatly appreciated!


Try CiviTeacher: the online video tutorial CiviCRM learning library.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 09, 2009, 08:56:30 pm

can you check your apache logs and see what the request is when you press: "save and send test e-mail". it should be a POST followed by a GET (similar to the otehr buttons)

Not sure why in your case that is not submitting a POST request. All POST request should trigger the postProcess function (assuming they do not have any validation errors)

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 10, 2009, 10:05:41 am
Hi thanks,  here is the POST from my access log

97.115.118.234 - - [10/Mar/2009:09:59:28 -0700] "POST /drupal/civicrm/admin/setting/smtp HTTP/1.1" 200 50189 "http://irest.us/drupal/civicrm/admin/setting/smtp?reset=1" "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.7) Gecko/2009021910 Firefox/3.0.7 (.NET CLR 3.5.30729)"

There was no GET following this POST, that was the last line in the access log.  I tried it again.  Same result.   After I click "Save and Test Email" I get a single post like the one you see, but no GET.  Now there are two POSTs in a row in the access log, but no GETs.

Would it help you to log in to my site and see for yourself?  I can PM you the username and password.
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 10, 2009, 10:44:32 am

sure, can u get on IRC and we can chat there

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
oops one last snag?
March 12, 2009, 06:50:23 pm
Hey, thanks so much for the quick fix, glad to know it was a "real bug".

Note, I found one last bug I think.  Now through Global Settings > SMTP I am able to send myself a test message and I receive a status of "success" as well as the test message.

However, when running a through a live event registration form like this one:
http://irest.us/drupal/civicrm/event/register?id=1&reset=1

I am able to register for the event, my registration is put in the database, and I receive a confirmation email but I also get an error message on the page.  See screenshot attached.

It is not a live event or public site, you are welcome to register for this event using the MC test account # 5424000000000015 and see the error yourself.

Ideas?  thanks.
« Last Edit: March 12, 2009, 08:38:57 pm by Stoob »
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Sunil

  • I post frequently
  • ***
  • Posts: 131
  • Karma: 23
  • The community around a product more important than the product itself?
    • CiviCRM
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 12, 2009, 10:00:37 pm
Hi
Quote
I am able to register for the event, my registration is put in the database, and I receive a confirmation email but I also get an error message on the page

I try with event registration
got the SMTP error Message and also got the Email receipt from authorized .net payment gateway and not from the CiviCRM
(after registration there should be two emails, one from Authorized .net and second from the CiviCRM)

Received Receipt contain following part
Quote
************* TEST MODE *************

========= GENERAL INFORMATION =========

Merchant : CTB iRest
Date/Time : 12-Mar-2009 09:48:26 PM
Transaction ID : 0

========= ORDER INFORMATION =========
Invoice Number : 068fafc23f092761a4d3
Description : Online Event Registration: iRest Level 2 Training (San Rafael, CA)
Total : US $1250.00
Payment Method : Visa
...
...


Means your SMTP settings are wrong, plz check it.

sunil
« Last Edit: March 12, 2009, 10:10:37 pm by Sunil »
The community around a product more important than the product itself?

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 13, 2009, 12:14:40 pm
Thank you for your response Sunil.  Respectfully, though, I have already checked my SMTP settings -- they are correct.  I detail all the information in the posts above.

 How can I be sure?  This is why...  Not only does the "Save and Send Test Email" button work, thanks to Lobo, but I receive the test email promptly in my inbox via SMTP.  So, the problem is that in Global Settings > SMTP configuration   CiviCRM says my SMTP settings are correct yet in CiviEvent it says my settings are wrong with the same email address. 

Would could be the problem?  It makes no sense that the SMTP settings work for PEAR Mail in one situation but not in the other situation unless CiviCRM is transmitting and/or interpreting the PEAR Mail response differently.  Also please note the 3 screenshots detailing the problem.  I am trying to be very very thorough and help you test and debug CiviCRM software, but I am not a CiviCRM developer, so I need your help to fix it.  I am trying very hard to be professional, helpful and nice and contribute to this project as best as I can and make good software better.  Help...please?
Try CiviTeacher: the online video tutorial CiviCRM learning library.

Donald Lobo

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 15963
  • Karma: 470
    • CiviCRM site
  • CiviCRM version: 4.2+
  • CMS version: Drupal 7, Joomla 2.5+
  • MySQL version: 5.5.x
  • PHP version: 5.4.x
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 13, 2009, 01:09:37 pm

stoob:

your best bet is to do a google search and find out the cause of the smtp error: "failed to add recipient...."

if smtp gives us an error message we basically are just guessing that the settings are wrong. In your case the settings are right, but its the addRecipients call that is failing.

lobo
A new CiviCRM Q&A resource needs YOUR help to get started. Visit our StackExchange proposed site, sign up and vote on 5 questions

CiviTeacher.com

  • I live on this forum
  • *****
  • Posts: 1282
  • Karma: 118
    • CiviTeacher
  • CiviCRM version: 3.4 - 4.5
  • CMS version: Drupal 6&7, Wordpress
  • MySQL version: 5.1 - 5.5
  • PHP version: 5.2 - 5.4
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 16, 2009, 05:31:11 pm
Found the problem and fixed, hopefully this may help others with my situation.  It's a combination of CiviCRM's code and my hosting company's email policy.  Depending on how you feel, it might be a consideration to change the default behavior of SMTP emails in Civi, but maybe not.

Hosting Company Policy: An email may not be sent by SMTP unless the account used to authenticate the send is the same email as the "from" email in the header.  Why?  Maybe some security thing, but it's their policy not mine.  I confirmed this outside of the CiviCRM environment testing PEAR Mail directly and the host confirmed my findings. 

CiviCRM code: Emails are sent "to" and "from" the same address during SMTP testing.  This is the behavior default.  See code below. 

File: /CRM/Admin/Form/Setting/Smtp.php  lines 92-94, 104, & 129
Code: [Select]
                $userID  =  $session->get( 'userID' );
                require_once 'CRM/Contact/BAO/Contact.php';
                list( $fromDisplayName, $fromEmail, $fromDoNotEmail ) = CRM_Contact_BAO_Contact::getContactDetails( $userID );
                $from = '"' . $fromDisplayName . '"' . "<$fromEmail>";
                $headers = array(   
                                 'From'                      => $from,
                                 'To'                        => $from,

What this meant is that I couldn't successfully test my SMTP settings or send Event Registration confirmation emails unless the email on my Drupal user account and/or Event registration info is the same as the as the email associated with CiviCRM SMTP configuration server settings.  This was not the case for me, and I hadn't yet set up any "Options > From Email Addresses" yet.  Once I set up consistently the 3 following things: SMTP settings, "From Email Addresses" and "Configure > Domain Settings" testing SMTP started to work.  Lo and behold, the Event Registration confirmation emails also started to work, now that the event "from" address was consistent across the board.

I don't know if this host I have been forced to work with, InMotion, is the first of many to come with this SMTP policy or if they are just an isolated case.   Some consideration may be given to the default behavior of SMTP "from" emails with CiviCRM and if it is appropriate any longer to have emails sent "to" and "from" the same address as a default.  Perhaps it would be better if the default email is "from" the "Configure > Domain Settings" instead. 



Try CiviTeacher: the online video tutorial CiviCRM learning library.

Dave Greenberg

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 5760
  • Karma: 226
    • My CiviCRM Blog
Re: Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail
March 17, 2009, 11:52:32 am
Using the default FROM address for the test email, AND displaying the FROM and TO email addresses used in the test seem like good improvements - and hopefully will help make debugging these situations less painful. I've filed an issue for 2.2.1:

http://issues.civicrm.org/jira/browse/CRM-4250
Protect your investment in CiviCRM by  becoming a Member!

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Installing CiviCRM »
  • Drupal Installations (Moderator: Piotr Szotkowski) »
  • Can't Get "Save and Sent Test" to work after setting up SMTP Outgoing Mail

This forum was archived on 2017-11-26.