Support ⇒ Explain Please ⇒ Help with send_mail parameters ⇒ Community Forums ⇒ CPG Dragonfly™ CMS
Forum IndexExplain Please

Help with send_mail parameters Reply to topic


Hi,

Can anyone help with this? I need to add a few lines to register.php in order to send an email from the email address supplied by a new member to another email address (our newsletter provider) but I'm struggling to understand the order of paramaters I need to supply to send_mail. I see the following two example in register.php:

send_mail($mailer_message,$message,0,$subject,$user_email,$username,$from)

and

send_mail($mailer_message,$message,0,$subject)

but all I really need to do is send a mail from the user's email address to the subscribe address supplied by our newsletter host, I don't necessarily need to include a subject or body but perhaps doing so would be wise to avoid spam filters. I can assign the user's address to $from but I guess the biggest thing I'm struggling with is where to include the To: address in the list of values passed to send_mail? Any help much appreciated, thank you!

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


dragonflycms.org/Docs/..._mail.html

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial

Last edited by DJ Maze on Sat Mar 28, 2015 2:21 pm; edited 1 time in total


Excellent, many thanks DJ, that's just what I was looking for. I understand from the argument decriptions that $message is basically the body/content of the message but I haven't quite understood what $mailer_message is or does (perhaps because I'm not a programmer) - do I need to worry about it in this context or just include it as it's mandatory? Does it just return a sort of of success/failure message which can, if desired, be echoed to the screen?

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


You can just ignore the contents of $mailer_message

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


Great, many thanks for clarifying, appreciate the quick reply!

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


Hi DJ, one last question? Is there any way to suppress $from_name completely so that only the email address (i.e. $from) appears in the From: line of the message header? I've tried setting $from_name = "" but the default value of the sitename is still included in the outgoing mail. Many thanks in advance.

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


use "\r\n"

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Fedora 25 / Apache 2.4.27 / MariaDB 10.1.26 / PHP 7.1.10 / Mercurial


Many thanks. It didn't quite work, producing a From name of " \n", so I changed it to just "\r" and that seems to have done the trick (strictly speaking there does still seem to be a blank character in the From line before the email address but it's not appearing in quote marks and my mail client is showing the email address as the From value in my inbox screen so I don't think it matters).

Thanks again for all your help!

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


Aaargh, so near to getting this finished but discovered one final issue!

I've set "Receive Newsletter" to "Hidden" via the Members Config -> Fields admin screen because I've replaced the newsletter sign up code in register.php with my own (to allow subscription to our third party newsletter provider via email as above) but I've noticed that Receive Newsletter is still a configurable field visible to the user on the My Preferences screen when they log in. I had imagined that this line would disappear having changed the setting to invisible. I'm going to start digging around to see if I can find a work out how to replace that line with something else (e.g. instructions to the member on how to unsubscribe from our third party newsletter) but if anyone can point me to the right place it would, as always, be appreciated.

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


I don't quite remember well, but wasn't the "hidden" option suppose to hide the field from the registration process only?

.:: I met php the 03 December 2003 :: Unforgettable day! ::.

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
CloudLinux / Apache 2.4 LSAPI / MySQLi 5.6 / PHP 5.6 / DCVS


Hi Nano,

Certainly it looks as though that's the way it works and I can't see any way to turn the DF newsletter off completely so that a member's subscription status doesn't appear on their preferences screen. I'm out of the office at the moment but when I get back later I'll start looking to see if a little editing of the existing code can get round this, in the meantime would you happen to know off the top of your head where I should be looking (i.e. for the code which displays the user preferences screen)?

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


That is the way it works. Always forget that and make same mistake!

Really want a Disable option. But that means a change to Admin configuration to offer Disable, plus change to My Profile to not display if disabled, and ditto to at least Registration, perhaps more. (And might break AccountPlus?)

How about a test to see if Newsletter module is present and ignore field if not?

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


Hmmm, this is tougher than I thought, I'm actually struggling to identify the file and code responsible for outputting the user preferences screen.

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1


If the URL you are looking for ends in Your_Account/edit=prefs/

Then modules > Your_Account > edit_profiles.php and search for prefs

If it isn't that one, the above should give you the breakdown. ( It was a bit easier to see before LEO Wink )

Pro_News CM™ - Content Management for Dragonfly CMS™

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
Linux / 1.3.39 - 2.4.9 / 5.5.42 - 5.6.16 / 5.4.37 - 5.5.11 / 9.4


OK, one option is to edit the following line in \language\english\your_account.php

define('_MA_RECEIVENEWSLETTER','Receive Newsletter');

e.g. changing it to

define('_MA_RECEIVENEWSLETTER','');

so that the Yes/No line on the preferences screeen isn't explicitly associated with the newsletter, although admittedly it'll now look a bit odd without an explanation as to what the Yes/No setting refers to. I just can't see which function is being called to output that entire screen in the first place though!

Note: WWW Private Listing - Staff Only

Server specs (Server OS / Apache / MySQL / PHP / DragonflyCMS):
linux/Apache 2.4.27/MySQL 10.1.26-MariaDB/PHP 5.2.17/Dragonfly 9.2.1

All times are UTC


Jump to: