Page 1 of 1
Sent SMTP mail arrives via PHP mail
Posted: 2020-11-14 15:16
by RonP
Hi,
In spite of setting the SMTP parameters I still get, every now and then, a mail send by PHP.
(every now and then .... in very random times)
My provider urged me to step over to SMTP so I did however....didn't help that much.
Any solution to be think of?
I use AppGini V05R84
Set code in config.php file
Code: Select all
'mail_function' => "smtp",
'smtp_server' => "smtp.mail.pcextreme.nl",
'smtp_encryption' => "tls",
'smtp_port' => "587"
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-13 10:42
by RonP
Hi There,
The problem still occurs, I can see in the php-mail.log that the mail still is send by PHP-mail and not by SMTP.
What can I do to have the mails sent by SMPT?
Ron
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-13 18:16
by jsetzer
Please check: are you calling the appgini built-in sendmail($mail) function or the php mail() function?
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-14 15:25
by RonP
Hi JSetzer,
Thanks for the reply.
It is not clear for me:
- Where do I call the mailfunction? Is this in one of the "Hooks files"?
- Is the mailfunction to be called within file: incFunctions.php?
If so, I've found:
In hooks file: contacten.php (a mail should be sent:
function contacten_after_insert($data, $memberInfo, &$args {
function contacten_before_update(&$data, $memberInfo, &$args) {
function contacten_before_delete($selectedID, &$skipChecks, $memberInfo, &$args) {
@mail(
// mail recipient
"{$data['Email']},
[email protected]",
// subject
"Heiloo Energie-Leden:{$data['Voornaam']} - {$data['Achternaam']} heeft zich als nieuw lid aangemeld",
// message
"Nieuwe inschrijving ingevoerd door:{$memberInfo['username']} \n\n".
$messageData,
// sender address
"From:
[email protected]"
);
Ron
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-14 15:54
by jsetzer
If you want to send emails using SMTP, configured in admin area, you will have to use the AppGini built-in sendmail($mail)-function and not the default PHP mail-function, I think.
See here:
viewtopic.php?t=2555#p8318
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-14 16:00
by jsetzer
It is fine to call sendmail(...) from within a hook function.
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-15 11:21
by RonP
Hi JSetzer,
I've done that before, however.... nope
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-18 10:48
by onoehring
Hi,
strange.
Did you try to force executing the sendmail for tests? What happens - nothing?
I would suggest you check your config.php file where the SMTP settings are saved. Are they correct? Maybe even try to create a new email account in your mail program and copy&paste the credentials from the config.php. Can you send mails?
I myself had a strange experience yesterday: A university IMAP account worked - the SMTP with the same credentials did not ... so strange things happen.
PS: I have created a helper function (see below) which essentially is the sendmail "a little easier to use".
Code: Select all
function myMail ($username, $email, $mailSubject, $mailMessage){
$mail_status = sendmail(array(
'to' => $email,
'name' => $username,
'subject' => $mailSubject,
'message' => $mailMessage
));
return $mail_status;
}
Olaf
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-18 13:16
by jsetzer
@Ron and @others:
Maybe this structured step-by-step guide which I have written today can help:
https://appgini.bizzworxx.de/appgini/st ... ing-mails/
@Olaf:
Wrapping the built-in
sendmail($mail) function is a very nice idea for beginners! Well done!
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-21 14:07
by RonP
Hi JSetzer and Olaf,
Thanks for the "tips".
Especially the "Step-by-Step article"
As my PHP is very poor I now wonder how I can the formerly used "PHP mail" parameters effective in the SMTP mail.
Code: Select all
@mail(
// mail recipient
"{$data['Email']},[email protected]",
// subject
"Heiloo Energie-Leden:{$data['Voornaam']} - {$data['Achternaam']} heeft zich als nieuw lid aangemeld",
// message
"Nieuwe inschrijving ingevoerd door:{$memberInfo['username']} \n\n".
$messageData,
// sender address
"From: [email protected]"
);
So, in the Subject I like to see back:
"Heiloo Energie-Leden:{$data['Voornaam']} - {$data['Achternaam']} heeft zich als nieuw lid aangemeld",
And in the Message:
"Nieuwe inschrijving ingevoerd door:{$memberInfo['username']} \n\n".
And what I've read:
No CC/BCC are allowed, however "the manger" should receive a copy of a send message.
How can I fix this all?
Ron
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-21 14:20
by jsetzer
@Ron: You are still using mail-command, but, as mentioned before, you have to use sendmail command if you want AppGini to send you mails using the SMTP parameters you have configured.
Please follow the step-by-step guide. I think everything you need has been described there, especially testing your SMTP parameters and using sendmail command in PHP.
Re: Sent SMTP mail arrives via PHP mail
Posted: 2020-12-21 15:28
by RonP
Jsetzer,
I've followed the Step-by-Step Quide, and all that works well.
Code: Select all
$mail = [
"to" => "{$data['Email']}",
"name" => "Verzonden door: {$memberInfo['username']}",
"message" => "$messageData",
"subject" => "Ledenadministratie: {$data['Voornaam']} {$data['Achternaam']} heeft een wijziging uitgevoerd",
"debug" => 4
];
I'm ashamed that I didn't look more precise.
Now I see that it works.
However: How to get a CC/BCC send?
Again sorry for the former post.
Thank you so much
Ron