The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

SMTP PHP Mail Not Routed Through Dedicated IP Address

Discussion in 'E-mail Discussions' started by deltaend, Oct 31, 2008.

  1. deltaend

    deltaend Registered

    Joined:
    Jan 30, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    So, I switched the option on in the WHM to send domain email out through dedicated IP addresses and it works great. The PHP based webmail clients built into cPanel work great and they send their emails from the correct IP address.

    However, when using a LOCAL PHP based SMTP client and sending mail through, it always comes from the shared IP address of the server, NOT the dedicated one.

    What I would love to know is... how do the native cPanel php based webmail apps route email through the system and how does that make them different than other PHP based authenticated clients?
     
  2. sparek-3

    sparek-3 Well-Known Member

    Joined:
    Aug 10, 2002
    Messages:
    1,384
    Likes Received:
    23
    Trophy Points:
    38
    cPanel Access Level:
    Root Administrator
    I believe this functionality is dependent on the envelope-sender used to send the mail.

    How are you sending mail in the PHP script?

    If you are using the mail() function, then you need to specify a correct envelope-sender (sometimes called a return-path) using the fifth parameter of the mail() function.

    http://us2.php.net/manual/en/function.mail.php

    This would be something like

    PHP:
    mail("to@address.com","Subject","Message","Additional Headers","-fsomeone@example.com");
    Where someone@example.com refers to a real e-mail address on the example.com domain that does exist. And example.com would need to have a dedicated IP with this exim functionality enabled.

    If you are using an SMTP class for sending mail with PHP, then you need to specify a real e-mail address on the account as the envelope-sender when constructing the message. The envelope-sender address is what is specified in the MAIL FROM: command when constructing an SMTP message.
     
  3. deltaend

    deltaend Registered

    Joined:
    Jan 30, 2007
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I love you.

    Yes, you hit the nail on the head in one. Now I am able to send out PHP based emails from the correct dedicated IP address as I should and apparently I can still spoof the emails as coming from a different source so people can just hit the reply button without worrying that they will return to the bounces email account if I format it correctly.

    Below are settings for PHPmailer class:

    $mail = new PHPMailer();
    $mail->IsSMTP(); // telling the class to use SMTP
    $mail->Host = "dedicatedipaddress"; // SMTP server


    $mail->AddAddress("targetemail@targetdomain.com");
    $mail->SMTPAuth = true;
    $mail->Username = "realusername";
    $mail->Password = "realpassword";
    $mail->From = "spoofedemail@spoofeddomain.com";
    $mail->FromName = "spoofedname";
    $mail->Sender = "realemailaddress@realdomain.com";
    $mail->SMTPDebug = true;
    $mail->Port = 25;

    $mail->Subject = "First PHPMailer Message";
    $mail->Body = "Hi! \n\n This is my first e-mail sent through PHPMailer.";
    $mail->WordWrap = 50;

    if(!$mail->Send()) {
    echo 'Message was not sent.';
    echo 'Mailer error: ' . $mail->ErrorInfo;
    } else {
    echo 'Message has been sent.';
    }


    I'm not sure if it works for other methods of emailing out, but I'm about to test. Thanks for the great intel!
     
Loading...

Share This Page