nuSendEmail: $from, $fromname ignored?

Questions related to using nuBuilder Forte.

nuSendEmail: $from, $fromname ignored?

Postby kev1n » Wed Oct 23, 2019 4:42 pm

Hi Steven,

Even when I pass a $from and $fromame in nuSendEmail($to, $from, $fromname ...), these arguments are not used when sending an email. Instead, the ones from the Email Settings are used.

Email Settings.png
Email Settings.png (6.03 KiB) Viewed 315 times


E.g. : I send an email providing these arguments:

Code: Select all
$to = "something@test.com";
$from = "nubuilder@test.com";
$fromname = "nuBuilder";
nuSendEmail($to, $from, $fromname ...),


The provided arguments are ignored but the "From address" test@test.com and "From Name" Tester from the Email Settings are used.
This was not the case with older nuBuilder versions.
kev1n
 
Posts: 411
Joined: Mon Oct 15, 2018 2:13 am

Re: nuSendEmail: $from, $fromname ignored?

Postby kev1n » Tue Nov 12, 2019 4:44 pm

Steven,

Do you know how this is supposed to work?

The provided arguments are ignored but the "From address" test@test.com and "From Name" Tester from the Email Settings are used.
This was not the case with older nuBuilder versions.


Related question:
viewtopic.php?f=19&t=10105
kev1n
 
Posts: 411
Joined: Mon Oct 15, 2018 2:13 am

Re: nuSendEmail: $from, $fromname ignored?

Postby admin » Sat Nov 16, 2019 7:29 am

We are rewriting the nuEmail() function.

It will be done in about a week.


Steven
admin
Site Admin
 
Posts: 3193
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSendEmail: $from, $fromname ignored?

Postby kev1n » Mon Dec 30, 2019 9:05 pm

admin wrote:It will be done in about a week.


Since I haven't seen any updates for this, I uploaded my own patched file.

https://github.com/smalos/nuBuilder-Bug ... mailer.php

Modified rows:

Code: Select all
$nuEmailSettings->from_address  = $from_address != '' ? $from_address : _nuMarshallEmailSettingsHelper($setup, 'set_smtp_from_address');   
$nuEmailSettings->from_name   = $from_name != '' ? $from_name :  _nuMarshallEmailSettingsHelper($setup, 'set_smtp_from_name');   
kev1n
 
Posts: 411
Joined: Mon Oct 15, 2018 2:13 am

Re: nuSendEmail: $from, $fromname ignored?

Postby admin » Sat Jan 11, 2020 7:40 am

kev1n,

I have added your improvements now in the latest version on Sourceforge.

Thanks

If you could test what I've done and write an explanation of how to use your nuEmail(), I'll add it to the wiki.


Steven
admin
Site Admin
 
Posts: 3193
Joined: Mon Jun 15, 2009 9:53 am

Re: nuSendEmail: $from, $fromname ignored?

Postby kev1n » Mon Jan 13, 2020 10:29 pm

Tested & works for me.

Documentation:

$object = nuSendEmail($to, $from, $fromname, $content, $subject, $filelist, $html = false, $cc = "", $bcc = "", $reply_to_addresses = array())

Parameters

$to : The email address you want the message to go to.

$from : The email address you want to appear in the email header. If this parameter is left empty, the email address from Setup -> Email Settings is used.

$fromname : The name you want to appear in the email header. If this parameter is left empty, the email address from Setup -> Email Settings is used.

$content : The content of the message, if the parameter $html is set true, then you can include html content

$subject : The email subject you want to appear in the email header

$filelist : If you do not want to send attachments, you must still supply an empty array here, if you do want to send attachments, this array needs in the following format $filename=>$filesource

$html : true or false

$cc : Carbon copy: When you CC people on an email, the CC list is visible to all other recipients.

$bcc: Blind Carbon Copy: Other recipients will not see the Bcc recipient's email address in the mail.

$reply_to_addresses: It is the email address that the reply message is sent when you want the reply to go to an email address that is different than the From: address.


Return Value

$object: If an error has occurred the function returns false, as well as the error message. Else the function will return true and a confirmation message of "Message sent successfully" will be returned.


Description

Sends an email using the settings stored in Setup -> Email Settings


Example

$r = nuSendEmail('to_email@test.com','from_email@test.com','From nuBuilder','Content here','Subject here', [], true, 'cc_email@test.com', 'bcc_email@test.com')

nuDebug()

[0] : Array
(
[0] => 1
[1] => Message sent successfully
[2] =>
[3] =>
)
kev1n
 
Posts: 411
Joined: Mon Oct 15, 2018 2:13 am

Re: nuSendEmail: $from, $fromname ignored?

Postby admin » Tue Jan 14, 2020 8:19 am

kev1n,

Thanks for that man!

I appreciate all your help.

https://wiki.nubuilder.net/nubuilderforte/index.php/PHP#nuSendEmail


Steven
admin
Site Admin
 
Posts: 3193
Joined: Mon Jun 15, 2009 9:53 am


Return to General