Page 1 of 1

@mail using SMTP from settings?

Posted: 2017-11-26 20:08
by miteshpc
I have hooks created before the SMTP settings were introduced in admin area.

My hooks still send out email, but using the old SMTP settings, where to change those settings now?

Re: @mail using SMTP from settings?

Posted: 2017-12-10 04:31
by R Tammam
There is another function sendmail you can use and its paramters
assoc array $mail( ['to', 'name', 'subject', 'message'] )

Re: @mail using SMTP from settings?

Posted: 2018-06-11 10:08
by facos79
Hello,
how can I use the smtp parameters to send table records via email? I need to use SMTP SSL

Re: @mail using SMTP from settings?

Posted: 2018-06-13 13:24
by a.gneady
If you have configured SMTP SSL in the Admin settings page under the admin area, all you need to do is use sendmail() function instead of mail. Here is an example of how to use it (it takes its mail config from the admin settings page):

Code: Select all

sendmail(array(
   'to' => 'recipient email',
   'name' => 'recipient name (optional)',
   'subject' => 'Mail subject',
   'message' => 'Mail message, HTML allowed'
));

Re: @mail using SMTP from settings?

Posted: 2018-08-15 16:45
by jsetzer
Could you please support CC, BCC and ReplyTo fields in the future.

Your sendmail function should look something like this:

Code: Select all

function sendmail( ... ) {

        // ...
        
	$pm->addAddress($mail['to'], $mail['name']);

// NEW CODE BELOW ------------------------------	
        if ($mail['replyto'])
	    $pm->addReplyTo($mail['replyto']);
        if ($mail['cc'])
            $pm->addCC($mail['cc']);
        if ($mail['bcc']) 
            $pm->addBCC($mail['bcc']);
        
        // ....
}

Re: @mail using SMTP from settings?

Posted: 2018-08-23 14:23
by a.gneady
Thanks for the suggestion, @jsetzer. Added to our backlog now :)