Auto generate email account during Drupal account registration? - php

I was wondering how to auto generate a user email accounts in Drupal? I do not have a host currently but am trying to get my head around how this would be done.

The Postfix mail server allows you to use a set of MySQL tables to set up mail accounts. With a little bit of custom coding against hook_user(), you could have new users get added to your Postfix tables and thus have e-mail addresses all nicely setup ready to go.

There is a Drupal module for that: the Mailfix for Postfix module. Here is an excerpt from its project page:
... integrates Drupal with Postfix, providing email accounts to regular Drupal accounts.
For this module to work you must have previously installed and configured Postfix 2.1 or greater. A step-by-step installation guide for an Ubuntu 8.04 server is available at HowToForge.
Once your Postfix server is appropriately configured you may install this Drupal module.

The other way you could do it is by using exec on your local server to run a script which adds a mail account. It really depends on your server environment.

Drupal is not an email server - hence you must connect Drupal to an email server in some way, most likely through the use of a custom module.

Related

How to send emails using php via a localhost(MAMP) on Mac?

I am new to PHP and I am trying to build a form that will be used to send emails. The form has two inputs, one is for user email and the other is for the message. Once the user clicks on submit button an email is supposed to be sent to me.
I saw the PHP mail() function but I am not able to use it because I am on a local server that is MAMP and I am using Mac OS 11.4v,
PHP version: 7.4.12 ,
Apache Port: 80 (I don't know if this information will help but still I will provide it in case it does)
I saw various ways on the web to solve this problem but every solution is kind of different I am don't know what is right at this point. I know there are some changes to be made in the files of the MAMP folder but I don't know what are the steps and what will work.
Can anybody please help me out? Thanks in advance!
I've used a 3rd party SMTP service to send emails from local instances. I use Sendgrid since it's free for their lowest plan. The drawback is that you'd need to build the API integration with Sendgrid, so it's more work on that front.
I've also used Mailhog to intercept emails locally.
If you are developing WordPress locally, then the Sendgrid integration is ultra easy - just download the Sendgrid integration plugin.
I used the PHP mailer library and it worked.
Here is the link for the library: https://github.com/PHPMailer/PHPMailer/tree/5.2-stable
Go for the stable version of the library which is 5.2-stable. The instructions to use the library are provided in this GitHub link.
Remember you need a Gmail account from which you will be sending emails. You have to provide an ID and password for the same in the library. Also, you need to make this Gmail account less secure. Just search on google:- 'less secure apps' and you will find the link to make your account less secure.
For reference:- check out this youtube video:- youtube.com/watch?v=0luMSSesJBA

How to send an e-mail from a server on which I can't install anything?

I am hosting my website on https://www.gandi.net/en , thing is they don't allow connections over ssh only sftp.
I have a form on my website and want to allow user to contact me through that form. In other words an e-mail needs to be sent from form#mydomain.com to me#mydomain.com.
In order to do that there are a couple of options I tried, but none of them seems to work:
1) PHP's mail function: doesn't support authentification. In order to send an e-mail from form#mydomain.com I need to authenticate. And that doesn't seem to be possible with the mail-function
2) PHPMailer: I saw many people recommending this solution. I downloaded their sources and had a look. It seems like in order for it to work you need to actually install PHPMailer using composer. I can't run composer via sftp...
What other solutions exist? Or what workaround exists?
Thanks!
2) PHPMailer: I saw many people recommending this solution. I
downloaded their sources and had a look. It seems like in order for it
to work you need to actually install PHPMailer using composer. I can't
run composer via sftp...
You don't need to run composer, just download the PHPMailer files manually and upload it via sftp. Composer just makes it easier to install packages, the PHPMailer itself existed long before Composer was a thing.
If you don't know how to install it without Composer, take a look at this answer.
You can give swiftmailer a try: https://swiftmailer.symfony.com/
It is used by Yii2 Framework as well.
If I am not mistaken, for most if not all PHP extensions, you can integrate it into your website by using composer from your own development machine, and then you'd upload the source using FTP. You don't need to use composer on the host server.
I have used swiftmailer with Yii2 websites on a public host and I didn't have to do any special setup on the host.
If all else fails, change host. Get a refund and use your new host's web transfer services to move with minimum effort.
Looks like if you use a SPF TXT record in your DNS setup for their Simple Hosting package, you should be able to use mail() as-is without having to authenticate to your mail host:
# 10800 IN TXT "v=spf1 ip4:217.70.176.0/21 ip6:2001:4b98:c::/48 ip4:217.70.185.10 ip4:173.246.97.150 ip4:217.70.186.165 ptr ?all"
Source:
http://wiki.gandi.net/en/dns/zone/spf-record
Which has this quote:
This Simple Hosting records is only used if you plan to send e-mails through your website (via contact form, etc..)
After you've submitted each of these changes, be sure to activate the new version of your zone file, and keep in mind that it will take about 3 hours for it to take full effect due to the standard DNS propagation delay.
You can confirm the SPF TXT record is deployed using various online SPF testing tools.
Since a lot of users have the ability to edit StackOverflow posts, I recommend going to the source and copying and pasting the appropriate SPF record directly to avoid shenanigans. Also the Gandi Wiki will always have the latest list of IPs whereas this post may go stale after 6 months.
I recommend Composer-less CubicleSoft Ultimate E-mail Toolkit or one of the other already mentioned libraries over directly using the built-in PHP mail() function. The PHP mail() function is very misleading. It simply drops a properly prepared mail message into the mail queue on the local host. However, e-mail is very complex and really needs a library even for the most basic PHP mail() use-cases.
If you want to use one of the other Composer-enabled libraries but don't want to upload thousands of little rinky-dink files that comes with Composer-enabled software, then check out CubicleSoft Decomposer. Decomposer takes an entire Composer project tree and generates standalone builds with 1-2 files as the output.

How to test PHP send mail on local server with MAMP Pro

I have a small web form that on submission triggers a mail script that sends an email to the address given to verify their email address.
I want to test this on my local server using MAMP Pro. I am totally confused from the info I have sourced that holds different advice and requirements.
I use Dreamweaver (DW) with WebAssist (WA) extensions to build my PHP scripts and when I contacted WA support to ask how to enter the correct settings with their DW plugin to work with MAMP pro they told me..
To have your localhost send email you need to install a local SMTP server configured for email relay.
If you want to use a remote smtp server you would likely have to use the PEAR mail option for authentication.
This has thrown me as I can't see anywhere in any MAMP Pro documentation about having to install SMTP servers and I know nothing about PEARL.
The following Blog makes it sound simple..
http://blog-en.mamp.info/2009/09/how-to-sending-emails-with-mamp-pro.html
But it obviously isn't as I have tried these Postfix settings with know joy.
I have also seen this post..
Test emails locally with mamp
..that gives a method using gmail but I just can't make sense of it as It appears that the MAMP interface may have changed since this was written.
Plus I am not familiar with using Terminal.
If anyone can shed some light on this to point me in the right direction I would be most greatfull
You can use Mailhog to achieve this. I wrote a tutorial on Medium.
Install mailhog using Homebrew (if you don't have Homebrew installed, check out the instructions here: https://brew.sh/):
brew install mailhog
Open MAMP Pro and go to the “Postfix” tab. Make sure the checkbox next to “Include Postfix service in GroupStart” is checked.
Use these setting for Postfix:
Fill in your domain name in the field “Set domain of outgoing e-mails to:”
Check “Use a Smart host for routing”
“Server name:” is 127.0.0.1:1025 (this is the SMTP port Mailhog uses)
Set “Authentication” to “none”
Go to http://127.0.0.1:8025/ in your browser to see the mails sent by PHP.

Can we configure or install SquirrelMail or any other aplication in localhost(xammp or wamp)? [duplicate]

I have a web application developed in PHP and all users can access it via local network(xampp), now the users want to access their gmail,yahoo or any emails via localhost(xampp), I want something like MS-outlook to work in my xampp.
is there any solution ?
the propper way to do this is if you use email server at localhost better already install apache2 in your own device
also using postfix and dovecot will be very helpfull here some link
about webmail configuration in google cloud instance
https://medium.com/geekculture/how-to-host-a-personal-email-server-on-google-cloud-for-free-part-i-8124d65d1d25
perhaps that concept will help you to develop your own webmail in Local Area Network

How can create email id using shell_exec or exec in php?

How can create email id using shell_exec or exec commands in PHP.
That is: I want to create an email id in my web application.
All help is appreciated.
On Linux, you've got a few choices, but most aren't practical from a web script point of view, as they require root permissions and/or substantial modifications to the server for initial setup.
add an entry to /etc/aliases to forward your new virtual mailbox to an existing account (on the same system or elsewhere) (requires root permissions)
create a physical system account (requires root permissions)
Set up a virtual mail server using a standard SMTP server, mysql, and dovecot (I've used postfix for this successfully). Much harder, but makes adding accounts a snap as it's simply a new database record.
I would use an php email library like swiftmailer: http://swiftmailer.org/
It would be possible to compose an email by "exec" and another tool, but there are too many risks/problems with that approach.
In other words #Tobias, shahul it trying to create an e-mail account from command line.
#shahul, what kind of e-mail account are you trying to create? Is it a GMail/Yahoo!, etc free e-mail account or are you talking from an MTA level, and if an MTA, what operating system and MTA are you talking about?

Categories