Skip to content

Commit f76b8a8

Browse files
committed
Fix error message on failed mail sending
1 parent 5452ab2 commit f76b8a8

8 files changed

Lines changed: 28 additions & 8 deletions

File tree

conf/_application.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
* Release date (ISO)
2222
* @global string
2323
*/
24-
$app_date = '2019-07-04';
24+
$app_date = '2019-07-05';
2525

2626
/**
2727
* Long version string for checking differences

htsrv/anon_unsubscribe.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
else
8181
{
8282
$Messages->add( T_('Sorry, could not send email.')
83-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
83+
.'<br />'.get_send_mail_error(), 'error' );
8484
}
8585

8686
$Messages->display();

htsrv/login.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@
238238
if( ! send_mail_to_User( $forgetful_User->ID, $subject, 'account_password_reset', $email_template_params, true ) )
239239
{
240240
$Messages->add( T_('Sorry, the email with the link to reset your password could not be sent.')
241-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
241+
.'<br />'.get_send_mail_error(), 'error' );
242242
}
243243
else
244244
{
@@ -563,7 +563,7 @@
563563
else
564564
{
565565
$Messages->add( T_('Sorry, the email with the link to activate your account could not be sent.')
566-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
566+
.'<br />'.get_send_mail_error(), 'error' );
567567
}
568568
}
569569
else

htsrv/message_send.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -564,7 +564,7 @@
564564
else
565565
{
566566
$Messages->add( T_('Sorry, could not send email.')
567-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
567+
.'<br />'.get_send_mail_error(), 'error' );
568568
}
569569
}
570570
}

htsrv/register.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -551,7 +551,7 @@
551551
else
552552
{
553553
$Messages->add( T_('Sorry, the email with the link to activate your account could not be sent.')
554-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
554+
.'<br />'.get_send_mail_error(), 'error' );
555555
// fp> TODO: allow to enter a different email address (just in case it's that kind of problem)
556556
}
557557
}

inc/_core/_misc.funcs.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3830,6 +3830,26 @@ function check_cron_job_emails_limit()
38303830
}
38313831

38323832

3833+
/**
3834+
* Get additional error message on failed mail sending
3835+
*
3836+
* @return string
3837+
*/
3838+
function get_send_mail_error()
3839+
{
3840+
global $Settings;
3841+
3842+
if( $Settings->get( 'email_service' ) == 'smtp' && ! $Settings->get( 'force_email_sending' ) )
3843+
{ // Only SMTP is used:
3844+
return T_('Recipient email address does not seem to work.');
3845+
}
3846+
else
3847+
{ // PHP "mail" function is used by default or it was forced after failed SMTP sending:
3848+
return T_('Possible reason: the PHP mail() function may have been disabled on the server.');
3849+
}
3850+
}
3851+
3852+
38333853
/**
38343854
* Sends an email, wrapping PHP's mail() function.
38353855
* ALL emails sent by b2evolution must be sent through this function (for consistency and for logging)

inc/collections/_collections.init.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1478,7 +1478,7 @@ function handle_htsrv_action()
14781478
else
14791479
{
14801480
$Messages->add( T_('Sorry, the email with the link to activate your account could not be sent.')
1481-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
1481+
.'<br />'.get_send_mail_error(), 'error' );
14821482
// fp> TODO: allow to enter a different email address (just in case it's that kind of problem)
14831483
}
14841484
}

inc/email_campaigns/campaigns.ctrl.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,7 @@
441441
if( ! $edited_EmailCampaign->send_email( $current_User->ID, $test_email_address, 'test' ) )
442442
{ // Sending is failed
443443
$Messages->add( T_('Sorry, the test email could not be sent.')
444-
.'<br />'.T_('Possible reason: the PHP mail() function may have been disabled on the server.'), 'error' );
444+
.'<br />'.get_send_mail_error(), 'error' );
445445
break;
446446
}
447447

0 commit comments

Comments
 (0)