my tools: server= digitalocean domain= godaddy installed apache/2.4.18 php 7.0.30 ubuntu 16.04
i have tried install sendmail and configure it as below:
sudo apt-get install sendmail
and configure the /etc/hosts
sudo nano /etc/hosts
i am sure it contains 127.0.0.1 localhost localhost.localdomain myhostname and i made
sendmailconfig
yes for all questions in sendmail config. also restarted apache2 with
sudo service apache2 restart
it is not sending mail. can u help me?
i tried send mail with send.php it contains:
<?php
$to = 'sendto@outlook.com';
$title = 'title of mail';
$content = 'hello from world';
$titles = 'From: sendfrom@outlook.com' . "\r\n" .
'Reply-To: sendfrom@outlook.com' . "\r\n" .
'X-Mailer: PHP/' .phpversion();
mail($to, $title, $content, $titles);
?>
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Heya all,
In case anyone else stumbles upon this question I’ll try to provide points on what could be the problem here.
PORT 25: DigitalOcean block port 25 on new and sometimes older accounts. This is something DigitalOcean has been doing to reduce spam on it’s network. It is more that we simply cannot accurately determine who is going to send it.
Stopping spam is a constant fight, so DigitalOcean has implemented some restrictions on newer accounts. Having said that, you can always contact them and ask for the port block to be lifted on:
https://www.digitalocean.com/support/
More information here:
https://docs.digitalocean.com/support/why-is-smtp-blocked/
Use SSL/TLS ports 465/587: Using SMTP would be the way forward. For you to do that, you’ll need to use either port 465 or port 587
How to use SMTP with port 465/587 and PHP mail():
The built-in PHP
mail()
function does not provide an option to specify the SMTP server or the port to be used for sending emails. It’s just a simple interface for sending mail using the built-in mail server which is typically configured at the system level, and not meant for advanced email sending features.If you need more control over the mail sending process like specifying the SMTP server and port, using SMTP authentication, or sending HTML emails, it’s recommended to use a library like PHPMailer, SwiftMailer or Zend_Mail.
Here is an example of how to send mail using PHPMailer with SMTP on ports 465 or 587:
You can adjust the SMTP server, username, password, and port according to your mail server settings. Use
SMTPSecure = 'ssl'
andPort = 465
if your server requires SSL connection on port 465.Other Struff to try :
Check the Mail Queue and Logs: Sendmail logs its messages to
/var/log/mail.log
or/var/log/syslog
depending on your system configuration. Check these files to see if there are any error messages that could help you debug the issue. You can also usemailq
command to see if your mails are stuck in the queue.PHP Mail Configuration: Check your PHP configuration file (
php.ini
) to ensure that thesendmail_path
directive is set correctly. It should be something likesendmail_path = /usr/sbin/sendmail -t -i
.Sendmail Configuration: Make sure your Sendmail is configured correctly. The
/etc/mail/sendmail.mc
file is the configuration file for Sendmail. After any change in this file, you need to generate thesendmail.cf
file by runningm4 /etc/mail/sendmail.mc > /etc/mail/sendmail.cf
and then restart the Sendmail service.Hosting Provider Restrictions: Some hosting providers restrict outbound SMTP to prevent spam. Check with DigitalOcean to ensure they aren’t blocking outbound connections on port 25.
SPF Records: Check if your domain’s SPF records are set correctly. If not, your emails might be being marked as spam. An SPF record is a type of Domain Name Service (DNS) record that identifies which mail servers are permitted to send email on behalf of your domain.
Hello friend!
This email should fail to be delivered at outlook.com because your server will not be an authorized sender for outlook.com. Microsoft will drop this and consider it a spoofed/spam sender. You can read more about SPF, the underlying function for this, here:
http://www.openspf.org/FAQ/How_does_it_work
You will want the From email to always be from a domain that you can speak for, so that you can delegate the authority properly.
Kind Regards, Jarland