Reputation: 157
I designed a Intranet for the company where i work, my next job is to create a form in PHP, the goal of the form is to enable a user send a mail with a attached image to another companion of the company in his birthday, i did the form but is not working because i need to connect to the mail server of the company in the script, thing that i don´t know, i just know that they use microsoft outlook and the active directory, the intranet is not a FQDN, is not .com, in my script i want to make a connection, how i can do that?
this is my code until now:
if( $_POST) {
define('WP_USE_THEMES', false);
require('../wp-load.php');
function correo(){
$email =($_POST['email']);
$name = ($_POST['name']);
$mensaje = ($_POST['mensaje']);
$correo = ($_POST['correo']);
$attachment = array();
if ($answer == "p1") {
$attachment [0]= 'postal1.jpg';
}
if ($answer == "p2") {
$attachment [1]= 'postal2.jpg';
}
if ($answer == "p3") {
$attachment [2]= 'postal3.jpg';
}
if ($answer == "p4") {
$attachment [3]= 'postal4.jpg';
}
if ($answer == "p5") {
$attachment [4]= 'postal5.jpg';
}
if ($answer == "p6") {
$attachment [5]= 'postal6.jpg';
}
$to=$email;
$from="[email protected]";
$subject ='Feliz Cumpleaños!';
$message =$mensaje;
$headers = 'From: Alejandro Torres ' . $from . "\r\n";
$enviar= wp_mail( $to, $subject, $message,$headers );
if ($enviar) {
echo "El mensaje fue enviado con exito, checa tu buzon de mensajes <br>";
}else{
echo "El mensaje no fue enviado <br>";
}
echo $to."<br>", $subject."<br>", $headers."<br>",$message."<br>";
}
correo();
}
Upvotes: 0
Views: 61
Reputation: 5499
Are you allowed to send the mail through there Exchange server? if so ask if they enable STMP from outside for you. You would be able to send it through the STMP server to the other company(assuming the other company is not on the intranet).
In that case you could use and WP Mail STMP
plugin to configure the configurations. Perhaps this post will help you.
In case you are not allowed to send through the Exchange server but able to send through the internet maybe an mail service is a good idea? a mail service like: mailgun, mandrill etc. Install a plugin to configure the settings for it and your good to go.
When that's not even possible, what are you allowed to use? Else this post is rubbish.
Upvotes: 1