where are the mail() processes / functions located in the SMF folders

Started by rcane, January 30, 2022, 03:18:43 PM

Previous topic - Next topic

rcane

Is there a way I can find the mail functions that are within SMF?

I have a script outside SMF I'm working on that should be sending a test message to me but I think it's got to do with not have SMTP or PHPMail setup properly.


I know SMF mails out just fine so I was hoping to see where it points.   This is NOT a spamming quest or the like. 

I'm just learning php and want to see what I'm missing.

Arantor

The SMF mail routines are in Subs-Post but are hellishly complicated between the mail queue and the various handling that goes on.

How is your SMF setup exactly?

rcane

Quote from: Arantor on January 30, 2022, 03:31:53 PMThe SMF mail routines are in Subs-Post but are hellishly complicated between the mail queue and the various handling that goes on.

How is your SMF setup exactly?

I'm not sure I can answer that correctly.  Do you mean in terms of installation or configuration, because except for personalizing the installation I didn't make any major changes.

Arantor

You said SMF is working correctly, so whatever is set up in the Mail Settings page must work. What are those settings? Are you using an external SMTP for example?

These settings directly affect the methodologies SMF will use to send mail - and thus what might be feasible to do in your script... if you are doing external SMTP, trying to do it in an external script is a nightmare unless you include SSI.php, include Subs-Post.php and push it through SMF's mail code because it's actually really complex to do and SMF does it by hand.

rcane

to clarify, I'm not trying to mail or manipulate SMF in any way; the mail settings page though does show PHP and not SMTP (port 25).


I was making a testMail.php file that checked a random webpage to see if it contained a word (yeah, I'm original).   If the word was there, send an email. 

The "checking" part works fine; it echoes a *thumbs up* that it worked.

It'll even say the mail() tested TRUE (though I know it's not actually sending anything to me).

This is the mail part of the code.  For brevity I left out the webpage part and variables.  Suffice to say that syntactically this doesn't error-out on me.

if ($intext)  {
   
    echo $intext;
    mail($to,$subject,$message,$headers);
    echo "opinon posted";
if ( mail($to, $subject, $message, $headers)) {
      echo("Email successfully sent to $to...");
   } else {
      echo("Email sending failed...");
   }
   
} else {
   
    echo "nothing yet";
}


The script's file is in the root directory of  www.mydomain.com which is where I installed SMF.  I wasn't sure how folder structure impacts this.

rcane

Well, it emailed an internal [email protected] address. I had been testing it with my regular gmail/phone email since that was the goal.  So, I've narrowed it down to what--a hosting permission that I need to inquire about?


Arantor

Well... the first parameter you pass into mail() is the address you're sending to... so what is *that* being set to in your code?

rcane

Quote from: Arantor on January 30, 2022, 04:07:03 PMWell... the first parameter you pass into mail() is the address you're sending to... so what is *that* being set to in your code?

[email protected]


it's working fine.  it's not being allowed to send to [email protected] (for example).

Arantor

Are you sending a 'from' address in the headers? Does the from address match the domain you're sending from?

rcane

Quote from: Arantor on January 30, 2022, 04:11:25 PMAre you sending a 'from' address in the headers? Does the from address match the domain you're sending from?

lemme check.....

*does test*

well, yep, putting an email properly in the $from worked for out-of-domain message.

Now, it's not accepting gateway addresses (for example) @TXT.att.net.


.....

Arantor

Well, that's presumably to curtail spam. At this point you're going to be getting into things like whether you have SPF records, DKIM and ideally DMARC configured for outbound mail - and this is far out of scope for what we can offer support on here. But at the very least getting proper SPF records set up on your domain may well help.

Your host may be able to help on what the DKIM records should be since it'll be set up on their end as well if they have it.

rcane

Quote from: Arantor on January 30, 2022, 05:25:16 PMWell, that's presumably to curtail spam. At this point you're going to be getting into things like whether you have SPF records, DKIM and ideally DMARC configured for outbound mail - and this is far out of scope for what we can offer support on here. But at the very least getting proper SPF records set up on your domain may well help.

Your host may be able to help on what the DKIM records should be since it'll be set up on their end as well if they have it.

yeah, it seems to be hung on that.  I'll go check the records.


related, but not the focus here is a for-loop I made.  I tested an array of two (2) email address of mine.   

I wanted it to run the mail to each address in the array--so i'l be getting 2 emails.  For some reason it's send two to EACH address.  I'm sure it's a count thing.


$to = array("[email protected]", "[email protected]");


foreach ($to as $person) {
        mail($person,$subject,$message,$headers);
        echo "opinon posted";
        if ( mail($person, $subject, $message, $headers)) {
                echo("Email successfully sent to $person...");
            } else {
                    echo("Email sending failed...");
                    }
    }
            } else {
   
                echo "nothing yet";
                }
 


is it the if(mail(.....)) part?   Is it executing it a second time and not just evaluating it was true?

perhaps I need to make an && true right after the iterations.


like I said...new to this.

rcane

yeah, my bad.  the original iteration was all I needed.  I didn't realize the true evaluation WAS doing it a second time.   neat.

rcane

thanks for the relocation Kindred.  turned into scripting subject.

Advertisement: