Jump to content

Hi I have asked this here like a year ago, but I don't remember what I did, whent back to the post but I cannot find out what I did there.

 

So I want to send mails from php, I have followed this guide https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-postfix-as-a-send-only-smtp-server-on-ubuntu-16-04

 

But that doesent work, I know I cannot use port 25 so that might be the case.

 

How do I do this? I just want a send mail nothing else.

 

EDIT: Or I can use the ISP's smtp server, but then I need to know how to configure it, as PHPMailer gave me error 554 even tho I gave it the info the ISP says (port and smtp adress, no ssl no authentication).

Back-end developer, electronics "hacker"

Link to comment
https://linustechtips.com/topic/737175-send-mail-with-php-ubuntu-server/
Share on other sites

Link to post
Share on other sites

applications that use port 25 need to be run as root so that might be your problem with port 25. The instructions you have are a bit much for what you are trying to do and they are trying to do something special whereas you just want to send emails. All you should need to do is "sudo apt install php-mail". Unlike the link you provided, I have never had to change any default settings on ubuntu server just to send an email. I use w3 schools as a reference anytime i need a form or some sort of automated mail:

 

http://www.w3schools.com/php/func_mail_mail.asp

http://www.w3schools.com/php/php_ref_mail.asp

<?php
// the message
$msg = "First line of text\nSecond line of text";

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
mail("someone@example.com","My subject",$msg);
?> 

 

             ☼

ψ ︿_____︿_ψ_   

Link to post
Share on other sites

10 hours ago, SCHISCHKA said:

applications that use port 25 need to be run as root so that might be your problem with port 25. The instructions you have are a bit much for what you are trying to do and they are trying to do something special whereas you just want to send emails. All you should need to do is "sudo apt install php-mail". Unlike the link you provided, I have never had to change any default settings on ubuntu server just to send an email. I use w3 schools as a reference anytime i need a form or some sort of automated mail:

 

http://www.w3schools.com/php/func_mail_mail.asp

http://www.w3schools.com/php/php_ref_mail.asp


<?php
// the message
$msg = "First line of text\nSecond line of text";

// use wordwrap() if lines are longer than 70 characters
$msg = wordwrap($msg,70);

// send email
mail("someone@example.com","My subject",$msg);
?> 

 

I got it to work again, this time I have a guide written down. tho I have a question, it sends from my hostname, I want it to send from my domain :P how do I do this? all the guides I have followed still makes it send from hostname.

 

EDIT: I mean if I add the from headers it's correct, but I heard that this will make it go to spam what so ever since it's not a FQDN. and this fits whats going on since all the mails end up in spam even tho I allow from that domain.

Back-end developer, electronics "hacker"

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

×