Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

whm settings for php mail

Posted on 2013-05-22
5
Medium Priority
?
1,308 Views
Last Modified: 2013-05-22
I have a cloud server that where I host a few web sites. I'm using Apache and WHM control panel. I'd like to close my server to send emails if the php scripts is not PHPMailer script?

I want to let my users send email only with phpmailer. ( with a connection to a related mail account using an email address and its password ) I don't want a hacker abuse my php web sites to send their spam emails.

where can I change this settings?
0
Comment
Question by:Braveheartli
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39186774
You can't do that because PHPMailer can use at least 3 different methods of sending email.  Or do you mean the PHP mail() function?  Those are two different things although PHPMailer (which is a PHP program you can download) can use the PHP mail() function also.  It can also send directly to an external SMTP server and I don't remember what the third method is.  Direct socket connection I believe.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 39186790
On the WHM mail options for PHP, I think there is a way that only lets the server send email if I use an email account , ( username and password ) otherwise it shouldn't send email

The web site contact forms on my server should only send emails using the below code

<?php
require 'class.phpmailer.php';

$mail = new PHPMailer;

$mail->IsSMTP();                                      // Set mailer to use SMTP
$mail->Host = 'smtp1.example.com;smtp2.example.com';  // Specify main and backup server
$mail->SMTPAuth = true;                               // Enable SMTP authentication
$mail->Username = 'jswan';                            // SMTP username
$mail->Password = 'secret';                           // SMTP password
$mail->SMTPSecure = 'tls';                            // Enable encryption, 'ssl' also accepted

$mail->From = 'from@example.com';
$mail->FromName = 'Mailer';
$mail->AddAddress('josh@example.net', 'Josh Adams');  // Add a recipient
$mail->AddAddress('ellen@example.com');               // Name is optional
$mail->AddReplyTo('info@example.com', 'Information');
$mail->AddCC('cc@example.com');
$mail->AddBCC('bcc@example.com');

$mail->WordWrap = 50;                                 // Set word wrap to 50 characters
$mail->AddAttachment('/var/tmp/file.tar.gz');         // Add attachments
$mail->AddAttachment('/tmp/image.jpg', 'new.jpg');    // Optional name
$mail->IsHTML(true);                                  // Set email format to HTML

$mail->Subject = 'Here is the subject';
$mail->Body    = 'This is the HTML message body <b>in bold!</b>';
$mail->AltBody = 'This is the body in plain text for non-HTML mail clients';

if(!$mail->Send()) {
   echo 'Message could not be sent.';
   echo 'Mailer Error: ' . $mail->ErrorInfo;
   exit;
}

echo 'Message has been sent';
0
 
LVL 84

Expert Comment

by:Dave Baldwin
ID: 39186798
You can restrict the local mail server but 'class.phpmailer.php' includes all the methods that I was talking about.  The SMTP method and the socket method totally bypass the mail server on your site.
0
 
LVL 1

Author Comment

by:Braveheartli
ID: 39186997
is my web site safe considering php mails if I can use above code to send email on my contact form? is it possible to any body to force my server send spam emails?
0
 
LVL 84

Accepted Solution

by:
Dave Baldwin earned 2000 total points
ID: 39188488
By changing $mail->Host I can use any SMTP server in the world that I can log into and it will not go thru your mail server.  Also, you should know that most mail servers don't use SSL/TLS.  Gmail and AT&T/Yahoo do and some others but not most.
0

Featured Post

ATEN's HDBaseT Presentation at InfoComm 2017

Hear ATEN Product Manager YT Liang review HDBaseT technology, highlighting ATEN’s latest solutions as they relate to real-world applications during her presentation at the HDBaseT booth at InfoComm 2017.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
If you are a web developer, you would be aware of the <iframe> tag in HTML. The <iframe> stands for inline frame and is used to embed another document within the current HTML document. The embedded document could be even another website.
The viewer will learn how to dynamically set the form action using jQuery.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question