dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Can't send emails from server

Tue Mar 10, 2020 7:46 pm

Hi. I’d appreciate some help with my Raspberry Pi.(Full Buster installation).
I’m running a website on my raspberry pi and I have it connected to my router. It has LAMP installed and the website works fine except for the contact form. Visitors to my site fill out a comments or contact form and it should be sent to me by email through PHP.(I presume?)

It doesn’t send the email to me even though no error message is received when a visitor submits the comment. That leads me to believe that my raspberry pi is receiving the message but is just failing to send it to me. It’s entirely possible that my ISP prohibits the sending of emails but I can’t alert them to the fact that I’m running a web site from home.

The site registrar is domains.google.com. With so many technologies involved I don’t think I have any hope of fixing this problem so I was wondering if anybody could tell me where the comments submitted to PHP could be stored. Would it then be possible for me to access them?

Regards
Dermot

User avatar
Skraaj
Posts: 29
Joined: Wed Nov 20, 2019 11:35 pm
Contact: Website

Re: Can't send emails from server

Tue Mar 10, 2020 11:34 pm

Pastebin your postfix config. Can you send and receive emails normally?

Is the server supposed to send the email to an external address or to an account on your Pi?
codedoneright.eu – newbie friendly raspberry tutorials

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Wed Mar 11, 2020 4:15 pm

Skraaj wrote:
Tue Mar 10, 2020 11:34 pm
Pastebin your postfix config. Can you send and receive emails normally?

Is the server supposed to send the email to an external address or to an account on your Pi?
Thanks very much for your reply. I've spent the afternoon trying to install mailutils and postfix and other mail packages but the install hangs.
I didn't realise that a mail app wasn't part of Buster.
I've given up because this is just too complicated for me. I'm just going to leave my email available on the web site and delete the Contact page.
Thanks again

Dermot

User avatar
Skraaj
Posts: 29
Joined: Wed Nov 20, 2019 11:35 pm
Contact: Website

Re: Can't send emails from server

Wed Mar 11, 2020 5:03 pm

Try this https://codedoneright.eu/?page_id=786 I wrote it to be as easy as possible, if you run into any problems just shout. But it's REALLY simple if you just follow along and don't skip steps. I fought with email a lot myself, don't get discouraged!
codedoneright.eu – newbie friendly raspberry tutorials

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Fri Mar 13, 2020 10:37 pm

Hi and thanks for the further reply.
I finally got postfix and mailutils installed but still cannot send an email.

Hopefully the attached postfix config file will show what I've done incorrectly. Sorry it's in two parts from Print Screen.

My web site is https://www.turnitonfromanywhere.com and I have it on my raspberry pi hosted through domains.google.com

I would be happy enough if I could just get the emailed comments on my pi. They don't necessarily need to be sent to my email address.

Regards and Thanks again
Dermot
Attachments
postfix config1.jpg
postfix config1.jpg (210.11 KiB) Viewed 669 times
postfix config2.jpg
postfix config2.jpg (181.26 KiB) Viewed 669 times

User avatar
Skraaj
Posts: 29
Joined: Wed Nov 20, 2019 11:35 pm
Contact: Website

Re: Can't send emails from server

Sat Mar 14, 2020 3:09 am

Did you go through my tutorial? I can clearly see that you have misconfigured config e.g. "myhostname" does not reflect your domain, your cert file does not reflect your certificate etc.

Any logs you can share?

What is the output of "sudo sevice postfix status"?
codedoneright.eu – newbie friendly raspberry tutorials

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Sat Mar 14, 2020 4:35 pm

Hi. No I haven't completed your tutorial because I can't get over the first hurdle, the DNS configuration. My domain is domains.google.com and in the DNS section there there is no mention of an MX DNS record, SPF DNS record, PTR DNS record.
Can I assume that since my website actually works that I don't need to alter my DNS configuration.

Is there any point in going through the tutorial without having set up the DNS configuration properly? I will go through it anyway as it looks as if I'm going to have a lot of time on my hands for the next few weeks ;)

In my postfix config file should I replace every instance of "myhostname" with domains.google.com and mydomain with turnitonfromanywhere.com?
Attachments
postfix status.jpg
postfix status.jpg (160.17 KiB) Viewed 626 times

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Sat Mar 14, 2020 7:16 pm

Hi. I've started the tutorial and I've changed the N1 Hostname to to turnitonfromanywhere.com in raspi-config. I rebooted and logged in by using putty with the Ip address of the raspberry pi. I then logged in to the raspberry pi as turnitonfromanywhere.com and was asked for the password. I put in my pi user password but it didn't work. I tried "raspberry" and "password" but they didn't work either.

Regards
Dermot

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Sun Mar 15, 2020 8:37 pm

I won't e continuing with trying to get the email server working on my pi because google domains requires that I sign up for G Suite. It's the only way I could properly configure the DNS settings.
Thanks everyone.
Dermot

User avatar
DougieLawson
Posts: 39560
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Can't send emails from server

Mon Mar 16, 2020 12:03 pm

dermotx wrote:
Sun Mar 15, 2020 8:37 pm
I won't be continuing with trying to get the email server working on my pi because google domains requires that I sign up for G Suite. It's the only way I could properly configure the DNS settings.
Thanks everyone.
Dermot
Doesn't your existing ISP/email provider have a POP3/IMAP server for inbound email and an SMTP server for outbound email. Take a look at their website.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Fri Mar 20, 2020 2:02 am

Thanks for reply but I just can't manage this email stuff between the problems I have to overcome with my ISP, Google domains etc. Does anyone know of a contact form that just captures the form data and leaves it somewhere on the server where I could access it and do away with the need for the server to email it to me?

bls
Posts: 718
Joined: Mon Oct 22, 2018 11:25 pm
Location: Seattle, WA
Contact: Twitter

Re: Can't send emails from server

Fri Mar 20, 2020 3:36 am

dermotx wrote:
Fri Mar 20, 2020 2:02 am
Thanks for reply but I just can't manage this email stuff between the problems I have to overcome with my ISP, Google domains etc. Does anyone know of a contact form that just captures the form data and leaves it somewhere on the server where I could access it and do away with the need for the server to email it to me?
If I understand your question correctly, fetchmail might do what you want. It will pull mail from a pop or imap server and drop it into a local mailbox on your pi.
Pi tools:
Easily and quickly build customized-just-for-you SD Cards: https://github.com/gitbls/sdm
Free your network from your router's DHCP/DNS:https://github.com/gitbls/ndm
Easy strongSwan VPN installer/manager: https://github.com/gitbls/pistrong
Lightweight Virtual VNC Config: https://github.com/gitbls/RPiVNCHowTo

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Fri Mar 20, 2020 3:49 pm

Thanks for the suggestion bls but I don't think that will work. The problem is the mail server on my raspberry pi. I have my web site on my raspberry pi server which is hosted on domains.google.com. In addition my ISP is virginmedia.ie and It's proving very difficult for me to get any mail server working. Google domains make it difficult because they want you to subscribe to their G Suite and virginmedia don't let you run a mail server on their domestic router connection.
My understanding is that to accomplish what I want I need to set up the Contact Form on a page called say, contact.html. I've already done this and that part is no problem. Apparently this will activate a php file or script which will get the information from the contact form input and email it to the email address I specify in the php script or file. This is where I run into the problem. Sending the email to me requires an email server. If I could get the php file or script to JUST capture the form input and keep it on the pi web server, without emailing it to me, so that I could could access it directly from the pi it would satisfy my needs.

By the way if anyone wants a great guide for setting up your own web site I'd recommend thesitewizard.com (I've no relationship with them.)
Regards and thanks again.

User avatar
DougieLawson
Posts: 39560
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Can't send emails from server

Fri Mar 20, 2020 5:14 pm

I don't know for sure but based on the stuff I found on Virginmedia's website

POP3 server: mail1.eircom.net
SMTP server (ssl port 465): smtp.upcmail.ie

Userid (your Virgin ID): dermot.x@virginmedia.ie [or something like that]
Password: your Virgin password

https://www.virginmedia.ie/customer-sup ... n-macmail/

Looks like they've swallowed up some old ISPs (in the same way that Virgin in the UK took over from NTLWorld).
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Fri Mar 20, 2020 5:57 pm

Hi Doughie. Thanks for that. I'd still like to avoid going the email route for the reasons outlined previously. My email account is with Gmail and I'm not sure why you referenced Mac Mail. Was it so I could get the mail server information?

I've already tried to send a simple email from the command line but I can't get even something as simple as that to work.

I'm pretty sure that the problem is that google domains and/or virginmedia prevent the execution of php scripts, hence why I want to avoid emailing the form content if possible.
Regards and Thanks.

User avatar
DougieLawson
Posts: 39560
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Can't send emails from server

Fri Mar 20, 2020 9:08 pm

dermotx wrote:
Fri Mar 20, 2020 5:57 pm
Hi Dougie. Thanks for that. I'd still like to avoid going the email route for the reasons outlined previously. My email account is with Gmail and I'm not sure why you referenced Mac Mail. Was it so I could get the mail server information?

I've already tried to send a simple email from the command line but I can't get even something as simple as that to work.

I'm pretty sure that the problem is that google domains and/or virginmedia prevent the execution of php scripts, hence why I want to avoid emailing the form content if possible.
Regards and Thanks.
I referenced the Mac page because the Windows page had zero information.

The SMTP server can't tell where the mail originates, it's just a socket on port 25 or port 465 there no "mail-agent" stuff that gets checked by anything - SMTP (whatever flavour is a 1960s protocol).

viewtopic.php?t=263695
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Sat Mar 21, 2020 3:33 pm

Ok. Some progress at last. I copied the python code from the topic you suggested in your last reply and saved it as testmail.py. I modified it with my email to and from addresses and ran chmod +x testmail.py. I then ran python3 testmail.py and received the message as if by magic :)

So I think this is one of the biggest obstacles overcome. Thanks guys.

Any ideas on my next step in transferring the data in the form (name, email address and comment) into this python program and getting it to run when the "submit" button is hit?

Regards and thanks again.

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Sat Mar 21, 2020 4:10 pm

Found this site which I think will do what i want:http://raspberrywebserver.com/cgiscript ... ython.html

The site is very old though and the python code doesn't work for me. I'm messing around with it and trying to research cgi scripting as well.
Regards

dermotx
Posts: 23
Joined: Mon Dec 03, 2012 3:00 pm

Re: Can't send emails from server

Mon Mar 23, 2020 8:24 pm

Success at last :)
I now have the feedback form working perfectly. The problem was connected somehow with my xxxx@gmail.com address. It must have some difficulty with php scripts or something.
I changed my email to xxx@aol.com and it works no problem.
I followed the great tutorials on thesitewizard.com and they have a Form Wizard that does a lot of the hard work for you.
Thanks for all the suggestions.

Regards
Dermot

Return to “Networking and servers”