Jump to content

"Login/Register/Profile" module - how to change default "from" email address


7Studio
 Share

Recommended Posts

This is one of my first posts, so I would like to say hello to everyone!

I'm building a site where I'm using latest "Login/Register/Profile" module from @ryan .

Everything works great, except one small thing, while creating new account, in confirmation email, in section "from" I see email address in format like:

processwire@www.mydomain.com

I guess that I'm missing something obvious, but is there is a way to change "from" email address?

In the core "Forgot Password" module there is an option to set "from" email address,  but I don't see anything similar here.

I haven't' found any information about this in the documentation or in the forums.

Does anyone have some tips or suggestions how this email address can be changed?

Thanks in advance!

Tomasz

Link to comment
Share on other sites

I've checked out the module source and it doesn't seem to have a customizable `from` address field, so WireMail defaults to admin email.

public function ___send() {

    $from = $this->from;
    if(!strlen($from)) $from = $this->wire('config')->adminEmail;
    if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost; 

Add this line to site/config.php

$config->adminEmail = 'my@email.com';

If you want to change the admin email for just LoginRegister.module, than put the line above where you execute the module.

$config->adminEmail = 'my@email.com';
$modules->LoginRegister->execute();

 

  • Like 4
  • Thanks 1
Link to comment
Share on other sites

@abdus, thanks a lot!

I was trying to add the "from" email address directly inside the module function - sendConfirmationEmail(), but I was worried about the updates,

Setting admin email address directly in the config

$config->adminEmail = 'my@email.com';

works like a charm!
Thanks once again ;)

Link to comment
Share on other sites

11 hours ago, abdus said:

I've checked out the module source and it doesn't seem to have a customizable `from` address field, so WireMail defaults to admin email.

I think this default behaviour is totally wrong - $config->adminEmail should not be used as the fallback "from" address by WireMail. I opened a LoginRegister issue and core feature request.

  • Like 3
Link to comment
Share on other sites

@Robin S, you are right, if admin email address is used for admin notifications (as you've mentioned in issue, i'm still quite new to pw, didn't know that) then the best option would be to have a separate config for the "from" address for WireMail class, or at least separate option in the login/register module.

I did wanted to use generic noreply@mydomain.com email here, the same as for password reset. As for now I've added desired "from" email address directly in the module sendConfirmationEmail() function:

$mail = new WireMail();
$mail->from = ('noreply@mydomain.com');

But I hope your suggestion will be taken into consideration.
Thank you for your input!

Link to comment
Share on other sites

  • 9 months later...
On 10/13/2017 at 12:44 PM, 7Studio said:

@Robin S, you are right, if admin email address is used for admin notifications (as you've mentioned in issue, i'm still quite new to pw, didn't know that) then the best option would be to have a separate config for the "from" address for WireMail class, or at least separate option in the login/register module.

I did wanted to use generic noreply@mydomain.com email here, the same as for password reset. As for now I've added desired "from" email address directly in the module sendConfirmationEmail() function:


$mail = new WireMail();
$mail->from = ('noreply@mydomain.com');

But I hope your suggestion will be taken into consideration.
Thank you for your input!

this is not working anymore

and I am getting two mails 

mail confirm.png

Link to comment
Share on other sites

On 7/19/2018 at 11:35 AM, rareyush said:

this is not working anymore

and I am getting two mails 

mail confirm.png

Hi @rareyush,

I've just checked that once again and this solution still works fine on latest dev version of PW in one of our site (login register module in v 0.2):

in loginRegister.module file, after line 677:

$mail = new WireMail();

just add your email address:

$mail->from = ('noreply@mydomain.com');

or please post your changes to the original file.

 

Link to comment
Share on other sites

On 7/21/2018 at 1:38 AM, 7Studio said:

Hi @rareyush,

I've just checked that once again and this solution still works fine on latest dev version of PW in one of our site (login register module in v 0.2):

in loginRegister.module file, after line 677:


$mail = new WireMail();

 just add your email address:


$mail->from = ('noreply@mydomain.com');

 or please post your changes to the original file.

 

I did these changes  but still I am getting two emails for confirmation 

Link to comment
Share on other sites

39 minutes ago, rareyush said:

I did these changes  but still I am getting two emails for confirmation 

I have had a similar problem while using Googlemail / G-Suite as outgoing and incoming addresses.

Try as outgoing something like @yahoo.com and as recipient something like @gmx.net. You don't have to use those freemailers but you get the idea. Two totally separated servers and domains.

Another thing could be a thing in cPanel powered hostings. Those sometimes have kind of a hiccup with who is actually the mail server for that domain.

Link to comment
Share on other sites

On 7/22/2018 at 4:59 PM, rareyush said:

I did these changes  but still I am getting two emails for confirmation 

No idea why this may happens, maybe you have some third party modules installed that affects wiremail class? Maybe you can check if the same issue appear on clean install? What about @wbmnfktr suggestions?

Link to comment
Share on other sites

On 7/22/2018 at 9:07 PM, wbmnfktr said:

I have had a similar problem while using Googlemail / G-Suite as outgoing and incoming addresses.

Try as outgoing something like @yahoo.com and as recipient something like @gmx.net. You don't have to use those freemailers but you get the idea. Two totally separated servers and domains.

Another thing could be a thing in cPanel powered hostings. Those sometimes have kind of a hiccup with who is actually the mail server for that domain.

I have my site on my own vps using centos and centos web panel and using default mail services there.

On 7/27/2018 at 9:45 PM, 7Studio said:

No idea why this may happens, maybe you have some third party modules installed that affects wiremail class? Maybe you can check if the same issue appear on clean install? What about @wbmnfktr suggestions?

I checked there no 3rd party module present 

Link to comment
Share on other sites

  • 2 months later...
  • 1 year later...

And fast forward to 2020, has anyone figured this out yet? 

Tried doing this but as expected, it is overwritten. ? Changing the config is out of the question because this would mean all other updates will bounce off. 

 

	protected function sendConfirmationEmail($email, $confirmCode) {
		
		$config = $this->wire('config');
		$confirmURL = $this->wire('page')->httpUrl() . "?register_confirm=" . urlencode($confirmCode);
		
		$mail = new WireMail();
		$mail->subject(sprintf($this->_('Confirm account at %s'), $config->httpHost)); 
		$mail->to($email);
		$mail->from('noreply@domain.com');

 

Link to comment
Share on other sites

@Pip You don't have to hack the core module file, as suggested by abdus above, you can define admin email address in your config.php file, so it won't be overwritten by any updates:

On 10/12/2017 at 11:53 AM, abdus said:

I've checked out the module source and it doesn't seem to have a customizable `from` address field, so WireMail defaults to admin email.


public function ___send() {

    $from = $this->from;
    if(!strlen($from)) $from = $this->wire('config')->adminEmail;
    if(!strlen($from)) $from = 'processwire@' . $this->wire('config')->httpHost; 

Add this line to site/config.php


$config->adminEmail = 'my@email.com';

If you want to change the admin email for just LoginRegister.module, than put the line above where you execute the module.


$config->adminEmail = 'my@email.com';
$modules->LoginRegister->execute();

 

 

Link to comment
Share on other sites

5 hours ago, 7Studio said:

@Pip You don't have to hack the core module file, as suggested by abdus above, you can define admin email address in your config.php file, so it won't be overwritten by any updates:

 

Thanks on this! 

Really look forward on the pull request to go through. 

  • Like 1
Link to comment
Share on other sites

9 hours ago, 7Studio said:

$config->adminEmail = 'my@email.com'; $modules->LoginRegister->execute();

Tried this. Though theoretically it is sound, email address is still stiff. I got my admin email address still.

Worst even if I do this, my Login Register comes out empty. 

I have do this in order to work (just to have the module work work): 

9 hours ago, 7Studio said:

<?php $config->adminEmail = 'my@email.com'; ?>
<?=$modules->LoginRegister->execute(); ?>

 

Take note: Email address is still the same as admin.

I've checked the error logs, everything seems to be in  working order. 

Link to comment
Share on other sites

I tried changing my admin email address. It's still stuck with the old one. Searched the whole database as well as any hard coded ones, none. 

What sorcery is this, @ryan

---- Sincerely, dumbfounded struck confused noob PW user. ?

Link to comment
Share on other sites

On 8/16/2020 at 4:05 AM, Pip said:

I tried changing my admin email address. It's still stuck with the old one. Searched the whole database as well as any hard coded ones, none. 

What sorcery is this, @ryan

---- Sincerely, dumbfounded struck confused noob PW user. ?

So apparently after going through stuff the reason as to why the email address never changed is due to the XAMPP settings. Despite setting the settings that way, it overwrites the sender still. 

Oh wells. Silly me calling it sorcery. ?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...