Jump to content
7Studio

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

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

Share this post


Link to post
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

Share this post


Link to post
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 ;)

Share this post


Link to post
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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
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.

 

Share this post


Link to post
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 

Share this post


Link to post
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.

Share this post


Link to post
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?

Share this post


Link to post
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 

Share this post


Link to post
Share on other sites
1 hour ago, rareyush said:

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

So... you haven't tested it with external addresses, right?

Share this post


Link to post
Share on other sites
On 8/1/2018 at 3:43 PM, wbmnfktr said:

So... you haven't tested it with external addresses, right?

like gmail and yahoo no, there are around 6 7 mail on that domain I have to migrate all the mail if I have to do that.

Share this post


Link to post
Share on other sites

I rebuild everything and still, I'm having a same problem 

receiving two emails whenever a user register.

Share this post


Link to post
Share on other sites

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');

 

Share this post


Link to post
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();

 

 

Share this post


Link to post
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

Share this post


Link to post
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. 

Share this post


Link to post
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. 😂

Share this post


Link to post
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. 😆

Share this post


Link to post
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

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...