Skip to content
← Back to Community
mail
Profile icon
Baconman321

How would I email someone using the mail() function?

Voters
Profile icon
Baconman321
Comments
hotnewtop
Profile icon
west

The simplest solution would be a mailto link. You can populate it with a form. Then people get to send the feedback from their own email. This also provides an avenue for you to reply to them.

Profile icon
Baconman321

@west id rather just read the feedback. Is there a way to get the mail function to work though?

Profile icon
west

@Baconman321 a quick google search yielded this https://www.arclab.com/en/kb/php/how-to-test-and-fix-php-mail-function.html I don't know php. However If this function is supposed to send an email from the server. This probably does not work from repl. Most hosting sites including google compute engine do not allow you to send mail on the normal port.

Profile icon
Baconman321

@west So is there any way that I can mail things to an email address?

Profile icon
west

@Baconman321 I don't think there's any way that you could use php to accomplish this. I suggest you look into mailto links. Using a mailto link makes it very easy to write a HTML form that pre populates an email. On submission it will open the user's email client. They just have to press send. If need more help with this I could write an example.

https://www.w3docs.com/snippets/html/how-to-create-mailto-forms.html

Also maybe add a link to the home page on each page.

Profile icon
Baconman321

@west I need something so that if they submit feedback, it will email it to me.

Profile icon
west

@Baconman321 here's an example of a mailto form.

Send

This works because mailto links are standard and they accept the prefilled values through the query string. The query string is added to the link by the form. Names and values from the form inputs are paired together

Profile icon
Baconman321

@west I think I'm supposed to use the @ mail function. I saw it in another program for php, But if I continue to use php which for some reason my mind is very closed upon, and it doesn't work, then I will use this form. Thanks for your help!

Profile icon
west

@Baconman321 No problem. Glad I could help.

Profile icon
Baconman321

@west Ok so I got sh: 1: /usr/sbin/sendmail: not found when I tried to mail. At least it is trying to work. However, when I try to install the sendmail package(which I learned I needed), but it gives the error:E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root?

Profile icon
west

@Baconman321 sorry I don't know Php so I can't help with sendmail of your permission error. The HTML form I suggested was a rough example. If you want more details see the link to the w3c article I previously posted

Profile icon
Baconman321

@west ok, ill ask someone else to help with that problem. If it truly won't work, I'll have to use ur great method. Thanks!