Mailer function won't work

Need help with the Administration of your Joomla! 3.x site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
petehurn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Fri Nov 15, 2019 11:49 am

Re: Mailer function won't work

Post by petehurn » Wed Nov 27, 2019 1:19 pm

toivo wrote:
Mon Nov 25, 2019 1:51 am
The lines from the log file everything.php you sent me show that the TCP port 25 on the web server does not accept the connection request from PHPMailer when Joomla tries to create a connection at the start of the SMTP dialogue (IP address redacted).

Send the extract of the SMTP connection attempt from the log to your host so that they can sort out the configuration of their mail server.

Code: Select all

2019-11-23T23:21:25+00:00    ERROR [ IP address ]    mail    Error in Mail API:
Connection: opening to localhost:25, timeout=300, options=array (
)
2019-11-23T23:21:25+00:00    ERROR [ IP address ]    mail    Error in Mail API:
Connection failed. Error #2: stream_socket_client(): unable to connect to
localhost:25 (Connection refused)
[/var/www/web/libraries/vendor/phpmailer/phpmailer/class.smtp.php line 298]
2019-11-23T23:21:25+00:00    ERROR [ IP address ]    mail    Error in Mail API: SMTP
ERROR: Failed to connect to server: Connection refused (111)
2019-11-23T23:21:25+00:00    ERROR { IP address ]    mail    Error in Mail API: SMTP
connect failed https://github.com/PHPMailer/PHPMailer/wiki/Troubleshooting
Ok I sent the file to my host technical support and they sent me this code back;

Please see below code that is recommended to be used as our SMTP server is not meant to be used through your website:

$mail = new PHPMailer;
$mail->setFrom('a.valid.email@the.domain.hosting.the.script', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
$mail->AltBody = 'This is a plain-text message body';

if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo;
} else {
echo 'Message sent!';
}

But what do I do with it, I suppose it has to be written somewhere??

 
User avatar
toivo
Joomla! Master
Joomla! Master
Posts: 12729
Joined: Thu Feb 15, 2007 5:48 am
Location: Zagreb, Croatia

Re: Mailer function won't work

Post by toivo » Wed Nov 27, 2019 2:12 pm

No need to write any code. The email options in Joomla work and the only challenge here is to find out which mailing option your host has made available to your web server.

Did your host explain that they do not allow you to use the mail server that may have been installed in the web server and that is usually available as the Mailer option 'Sendmail', or is "their mail server" perhaps installed in another server box that your web server does not have access to?

Maybe they meant but failed to explain properly that, instead of the Mailer option 'SMTP', your Joomla site should use the Mailer option 'PHP Mail', selected from the Global Configuration? If that is the case, select the option 'PHP Mail', repeat the test and if that fails, go back to your host. Your host manages the web server, including the mail settings, and your website should of course be able to send emails.

You could also use an external mail server like Gmail through the SMTP option, but Gmail requires additional configuration and SMTP may not be allowed by your host. Using an external mail server can also cause your emails to be blocked by the receiving mail servers, unless your domain has been configured with correct SPF details.
Toivo Talikka, Global Moderator

petehurn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Fri Nov 15, 2019 11:49 am

Re: Mailer function won't work

Post by petehurn » Thu Nov 28, 2019 5:19 pm

Ok I am stuck again now I gave the error code to my web host and they came back with;

Please see below code that is recommended to be used as our SMTP server is not meant to be used through your website:

$mail = new PHPMailer;
$mail->setFrom('a.valid.email@the.domain.hosting.the.script', 'First Last');
$mail->addAddress('whoto@example.com', 'John Doe');
$mail->Subject = 'PHPMailer mail() test';
$mail->msgHTML(file_get_contents('contents.html'), __DIR__);
$mail->AltBody = 'This is a plain-text message body';

if (!$mail->send()) {
echo 'Mailer Error: '. $mail->ErrorInfo;
} else {
echo 'Message sent!';
}

Now all I need is to find out how to utilise said code and where to put it??

petehurn
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Fri Nov 15, 2019 11:49 am

Re: Mailer function won't work

Post by petehurn » Thu Nov 28, 2019 5:29 pm

Wow thanks for all your help, I will contact my host and see what I can do.

 

Post Reply

Return to “Administration Joomla! 3.x”